Solved

Load a page into another frame

Posted on 2004-08-03
22
2,381 Views
Last Modified: 2008-01-09
Here is my HTML code

<script src="codepage.js" language="Javascript" type="text/javascript"></script>

<iframe src="blankpage.htm"  width="88" height="32"></iframe>

I need codepage.js to load this page into the iframe:

counter.asp?referer=REFERER GOES HERE

I know this may seem simple to most of you but I am a beginner to JS!

Thanks for reading this.
0
Comment
Question by:jonnyfb
  • 12
  • 10
22 Comments
 
LVL 63

Expert Comment

by:Zvonko
ID: 11704080
First of all neds your iframe a name:
<iframe name="myFrame" src="blankpage.htm"  width="88" height="32"></iframe>

Then your script file needs this statement:
window.onload=function(){window.frames.myFrame.src="counter.asp?referer="+document.referrer};


0
 
LVL 1

Author Comment

by:jonnyfb
ID: 11704214
Is there any way which I can redirect to counter.asp?userid=...&countid=...&referer=...

If I make the script name: code.js?userid=...&countid=...

Thankyou
0
 
LVL 63

Expert Comment

by:Zvonko
ID: 11704305
You cannot read the script script src in the script and you cannot change it dynamicaly.
Where should the values come from?
0
Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 
LVL 1

Author Comment

by:jonnyfb
ID: 11704326
Isnt there a querystring object?
0
 
LVL 63

Expert Comment

by:Zvonko
ID: 11704423
The name of querystring object is: windows.location.search
0
 
LVL 63

Expert Comment

by:Zvonko
ID: 11704636
And the syntax to pass the query string to the iframe is:
window.onload=function(){window.frames.myFrame.src="counter.asp?referer="+document.referrer+"&"+windows.location.search.substr(1)};

0
 
LVL 1

Author Comment

by:jonnyfb
ID: 11707775
Sorry I havent replied for soooo long. Would

windows.location.search.substr(1)

be the whole querystring?
0
 
LVL 63

Accepted Solution

by:
Zvonko earned 50 total points
ID: 11708509
Yeap, Whole string after the starting questionmark character.
0
 
LVL 63

Expert Comment

by:Zvonko
ID: 11708609
Why the grading B???
0
 
LVL 1

Author Comment

by:jonnyfb
ID: 11708629
Cause it diddnt work!
0
 
LVL 1

Author Comment

by:jonnyfb
ID: 11708639
My Iframe is still just blank!
0
 
LVL 63

Expert Comment

by:Zvonko
ID: 11708773
You did not state that. You simple closed the question.
I have a solution for you.
0
 
LVL 1

Author Comment

by:jonnyfb
ID: 11712932
I did not want to waste your time.
Sorry, could you tell me?
0
 
LVL 63

Expert Comment

by:Zvonko
ID: 11713199
Could you ask for grade correction here:
http://www.experts-exchange.com/Community_Support/

And you do not waste my time. I like answering questions ;-)
0
 
LVL 1

Author Comment

by:jonnyfb
ID: 11713209
If I correct the grade, will you give me the solution?
0
 
LVL 63

Expert Comment

by:Zvonko
ID: 11713470
My script line has two typos.
Take this one:

window.onload=function(){window.frames.myFrame.location="counter.htm?referer="+document.referrer+"&"+window.location.search.substr(1)};

0
 
LVL 1

Author Comment

by:jonnyfb
ID: 11713484
Ill test it now!
0
 
LVL 1

Author Comment

by:jonnyfb
ID: 11713516
I made counter.asp write the querystring and it said:

referer=&

So something must be wrong with window.location.search.substr(1)
0
 
LVL 63

Expert Comment

by:Zvonko
ID: 11713565
That's correct.
You cannot use document.referrer localy, only on web server.
And if you want to avoid the & char when no query was in parnet window, then you need and "if" statement. But that does not hurt in standard URL syntax.

If you realy want the & only when query are passed, then rewrite it to this:

window.onload=function(){window.frames.myFrame.location="counter.htm?referer="+document.referrer+((window.location.search)?"&"+window.location.search.substr(1):"")};



0
 
LVL 1

Author Comment

by:jonnyfb
ID: 11713583
Ill try it.
0
 
LVL 1

Author Comment

by:jonnyfb
ID: 11713603
Oh no! I think Ive explained a bit wrong!!

I want this querystring:

<script src="codepage.js? >>>>>userid=...&countid=...<<<<<" language="Javascript" type="text/javascript"></script>
0
 
LVL 1

Author Comment

by:jonnyfb
ID: 11713654
Im going now but I will be back later to check what help you have given. PLZZZ I am desperate!
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question