Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Frames: How to find out urls

Status
Not open for further replies.

JackTheRussel

Programmer
Aug 22, 2006
110
FI
Hi.

I have page where I have two frames

index.html

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">[/URL]
<html>
<head><title>My Frames</title>
</head>
<frameset rows="40%,60%">

<frame src="myUp.html" name="upframe">
<frame src="MyDown.html" name="downframe">

</frameset>
</html>

How can I find out in upframe.html, what is the location.href in downframe ?

I have tried solution like this:

MyUp.html

Code:
<html>
<head>
<script type="text/javascript">

var protocol = downframe.location.protocol;
var url = downframe.location.href;

document.write("Downframe address is " + url + " and the protocol is " + protocol + ".");
</script>
</head>
</html>

But this isn't workin.

I just get: downframe is not defined ?

I haven't use js much and I'm totally lost.

Can someone guide me?
 
Hi

The downframe is not child of myUp.html, but child of index.html. So referring to it from myUp.html must specify this too :
Code:
var protocol = [red]parent.[/red]downframe.location.protocol;
var url = [red]parent.[/red]downframe.location.href;
Note that if the first frame will load before the second frame, so the JavaScript code will be executed before having a document in downframe, your script will fail.

Feherke.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top