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!

url of frameset from child frame javascript

Status
Not open for further replies.

jwhittlestone

Programmer
Apr 19, 2006
16
GB
Hi there,

I'm having a bit of difficulty with a function that will open a link
depending on the calling frameset.
The function (promoLink()) is located in a frame
(trinity.getminted.com) and depending on the frameset
( or I wish to
open the link and respectively.

I am having trouble testing the properties of the frameset, I have
tried the following and javaScript does not seem to recognise them as a
string.

function promoLink()
{

if (parent.topFrame.location.href = ...
if (top.location.href=..
if (window.top.document.location.href=..
if (window.frames['topFrame'].location.href = ...
}

I'd appreciate any pointers! Thanks in advance for looking.
Jon
 
<framesets> contain <frames>. They do not have names although they can have IDs.

Reference a particular frame named gilbert

the main.html defining the frames
Code:
<frameset rows="50%,*">
  <frame name="gilbert" src="words.html">
  <frame name="sullivan" src="music.html">
</frameset>

a document in a frame, perhaps words.html
Code:
...
<script>
...
  //Test the url of the document currently in a frame.
  if ( window.gilbert.location.href [COLOR=red]==[/color] "walk_down_the_avenue.html" ) {
    //sing along.
  }
...
  //Load a new document into a frame.
  window.gilbert.location.href = "gentlemen_of_japan.html";
...
</script>
...

Note that the comparison operator in Javascript is two equal signs, ==. A single equal sign is the assignment operator. I suppose if ( a = b ) in Javascript might mean first assign the value of b to the variable a, then test that operation for true/false. I believe that makes sense in Perl, but I dont know whether it is valid Javascript.

Sorry if I got the facts wrong about Gilbert & Sullivan, I am a coder, not an entertainer. :)

HTH
 
Oh thanks Rac2, I want to test the href of the frameset, ie the Top page - do I specify a name or an ID for the frameset and test that? (which is on a diff. domain)the HTML for the frameset:
---
<frameset rows="110,*" frameborder="no" border="0" framespacing="0">
<frame src="header_mirror.html" name="topFrame" scrolling="No" noresize="noresize" id="topFrame" title="mirrorHeader" />
<frame src=" name="mainFrame" id="mainFrame" title="mainFrame" />
</frameset>

---


The script resides with the child frame
 
The outermost window can be referred to as top by Javascript in a page loaded in one of the frames within it.
Code:
top.location.href

A page containing frames -
Code:
<html>
<head>
	<title>Top URL</title>
</head>

<frameset cols="80%,*">
<frame name="left" src="hover_craft.html">
<frame name="right" src="top_url_checker.html">
</frameset>

</html>


A page loaded in a frame, in this case the page is top_url_checker.html -
Code:
<html>
<head>
	<title>Top URL</title>
</head>

<body>

The URL in the top window is:
<script>document.write(top.location.href);</script>
</body>

</html>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top