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 Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

different JS methods in window 1

Status
Not open for further replies.

rhcp

Programmer
Dec 27, 2003
11
IL
Hey All! this is what I got-

"parent.window.top2.location.href='a.html';"
(the code is in the main page along side the frames declerations)
there are 2 other ways to code it:


"parent.window.top2.location.href='a.html';"
-or-
"window.top2.location.href='a.html';"
-or-
"top2.location.href='a.html';"


all of these 3 lines work fine on my IE6. I search the net and found no answer as for which coding type of the 3 works best with all browsers and versions!!!!!!!!!
WHICH 1 of the 3 works best??????? and y?
Thx (the code in action is below)
***********************************************************
<html>
<head>
<script language=&quot;javascript&quot;>
function ccc()
{
parent.window.top2.location.href='a.html';
parent.window.top1.location.href='b.html';
}
</script>


</head>

<frameset rows=&quot;55px,24px,*&quot; cols=&quot;*&quot; frameborder=&quot;no&quot; >
**********************
*here are some frames*
**********************

</frameset>
<noframes><body>
</body></noframes>
</html>
**********************************************************
 
The default object is always [tt]window[/tt] (most of the time, there are a few exceptions), so:
[tt]parent.window.top2.location.href[/tt] is the same as
[tt]window.parent.window.top2.location.href[/tt] which is the same as [tt]window.top2.location.href[/tt] because the main window is (I think) its own parent. This also means that [tt]top2.location.href[/tt] is the same as [tt]window.top2.location.href[/tt] (because [tt]window[/tt] is the default object.

As far as I can see it doesn't matter which you use, but I would always use [tt]window.top2.location.href[/tt] because it's the clearest.

Hope this helps

[tt]________________________________________________________________
[pc2]Roger
Life is a game of cards in which the deck contains only jokers.[/tt]
 
Thanks woja, your explenation makes sense!!! window is a default so it will be best and safe like you said to choose:
&quot;window.top2.location.href&quot;. Thanks Again!.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top