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

Specify a target frame with document.location? 2

Status
Not open for further replies.

fpwr

Programmer
Joined
Oct 21, 2003
Messages
95
Location
US
Is is possible to specify a target frame when using a relocation script in a page like:

Code:
<script>
	document.location = &quot;[URL unfurl="true"]http://myURL...&quot;;[/URL]
</script>
<

It would look like the following in a link, however, I need it to automatically load (can't use meta tags---it's part of a decision tree) not be a link that needs to be clicked):

Code:
<a href=&quot;[URL unfurl="true"]http://myURL&quot;[/URL] target=&quot;mytarget&quot;></a>

Thanks.
 
<script>
parent.frameName.location = &quot;</script>

Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook (No, I'm not Rick)

zen.gif
 
That works---THANKS, but one followup. There is one circumstance where we'd like it to overide the frames and just load a normal page (session is expired---need to log back in). How do you do that? I tried:

Code:
parent._top.location = &quot;[URL unfurl="true"]http://myURL...&quot;;[/URL]

but that doesn't seem to work.

Thanks again.
 
top.location.href=&quot; should work.

You can also use window.open('targetName') if the reference between the various frames and popup windows gets broken somehow.

window.open('_top')

Adam
while(ignorance==true){perpetuate(violence,fear,hatred);life--};
 
this beats googles self focus function and answers your question

<input id=&quot;GB&quot; type=&quot;button&quot; value=&quot;Go&quot; onclick=&quot;navigate()&quot;>
<input type=&quot;text&quot; value='http:\\ id=&quot;TheAddress&quot; size=&quot;25&quot;>
<button type=&quot;button&quot; onclick=&quot;RBT()&quot;> Remove src attribute from iframe</button>
<span id=&quot;WebWindow&quot; style=&quot;display:none&quot;>
<iframe id=&quot;Top&quot; src=&quot;&quot; style=&quot;width:0px;height:0px;border:0px&quot;>
</iframe>
</span>
<script>
function navigate()
document.all.Top.src = TheAddress.value
document.all.WebWindow.style.display =(&quot;block&quot;)
end function
function RBT()
document.all.Top.src =(&quot;&quot;)
document.all.WebWindow.style.display =(&quot;none&quot;)
end function
</script>[wink]
 
<a id=&quot;link&quot; href=&quot;&quot;>Go To link</a>
<script>
function GoBack(){
h = window.history;
if (h.length) {
h.back();     
}
}
function ErrHandleLinker() {
var hrefs = new Array();
var hrefs[0] =&quot;http:\\//your back up
hrefs[1] =&quot;http:\\window.link.href=hrefs[1];
window.link.innerText=hrefs[1];
window.link.click();
if window.link.ondataavailable=false {
opener.window.execScript(GoBack); //not sure if this work
window.link.innerText=&quot;Sorry My Link has failed
}
}
</script>
 
Sorry About That...

<a id=&quot;link&quot; href=&quot;&quot; onclick=&quot;ErrHandleLinker()&quot;>Go To link</a>
<script>
function GoBack(){
h = window.history;
if (h.length) {
h.back();
}
}
function ErrHandleLinker() {
var hrefs = new Array();
var hrefs[0] =&quot;http:\\//your back up
hrefs[1] =&quot;http:\\window.link.href=hrefs[1];
window.link.innerText=hrefs[1];
window.link.click();
if window.link.ondataavailable=false {
opener.window.execScript(GoBack); //not sure if this work
window.link.innerText=&quot;Sorry My Link has failed&quot;;
}
}
</script>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top