Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Load a page into another frame

Posted on 2004-08-03
22
Medium Priority
?
2,389 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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 150 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
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…

971 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