Solved

Load a page into another frame

Posted on 2004-08-03
22
2,383 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
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…
Suggested Courses

734 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