Solved

Load a page into another frame

Posted on 2004-08-03
22
2,380 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Avoid defining the variables in the global scope; trying to define them in a local function scope. Because:   • Look-up is performed every time a variable is accessed.   • Variables are resolved backwards from most specific to least specific scope…
When you need to keep track of a simple list of numbers or strings, the Array object is your most direct tool.  As we saw in my earlier EE Article (http://www.experts-exchange.com/A_3488.html), typical array handling might look like this: (CODE) B…
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…

911 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

18 Experts available now in Live!

Get 1:1 Help Now