Solved

Load a page into another frame

Posted on 2004-08-03
22
2,378 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
 
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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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 …
This article discusses how to create an extensible mechanism for linked drop downs.
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…

743 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now