Load a page into another frame

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.
LVL 1
jonnyfbAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
ZvonkoConnect With a Mentor Systems architectCommented:
Yeap, Whole string after the starting questionmark character.
0
 
ZvonkoSystems architectCommented:
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
 
jonnyfbAuthor Commented:
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
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
ZvonkoSystems architectCommented:
You cannot read the script script src in the script and you cannot change it dynamicaly.
Where should the values come from?
0
 
jonnyfbAuthor Commented:
Isnt there a querystring object?
0
 
ZvonkoSystems architectCommented:
The name of querystring object is: windows.location.search
0
 
ZvonkoSystems architectCommented:
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
 
jonnyfbAuthor Commented:
Sorry I havent replied for soooo long. Would

windows.location.search.substr(1)

be the whole querystring?
0
 
ZvonkoSystems architectCommented:
Why the grading B???
0
 
jonnyfbAuthor Commented:
Cause it diddnt work!
0
 
jonnyfbAuthor Commented:
My Iframe is still just blank!
0
 
ZvonkoSystems architectCommented:
You did not state that. You simple closed the question.
I have a solution for you.
0
 
jonnyfbAuthor Commented:
I did not want to waste your time.
Sorry, could you tell me?
0
 
ZvonkoSystems architectCommented:
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
 
jonnyfbAuthor Commented:
If I correct the grade, will you give me the solution?
0
 
ZvonkoSystems architectCommented:
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
 
jonnyfbAuthor Commented:
Ill test it now!
0
 
jonnyfbAuthor Commented:
I made counter.asp write the querystring and it said:

referer=&

So something must be wrong with window.location.search.substr(1)
0
 
ZvonkoSystems architectCommented:
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
 
jonnyfbAuthor Commented:
Ill try it.
0
 
jonnyfbAuthor Commented:
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
 
jonnyfbAuthor Commented:
Im going now but I will be back later to check what help you have given. PLZZZ I am desperate!
0
All Courses

From novice to tech pro — start learning today.