...

View Full Version : Target="_top" not working from within javascript and frames.



KenHolle
06-13-2003, 10:36 PM
The web page uses frames. Within "text frame" is this code:

<script language="Javascript">
function formHandler(chapter)
{
var GOTO=document.chapter.url.options[document.chapter.url.selectedIndex].value;
window.location.href=GOTO;
}
</script>
</head>

<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">

<!-- content (start) -->

<table cellpadding=0 align=center border=0>
<tr>
<td valign=top>
<p>&nbsp;
<p class="bodytext">To download a document,
just select the one you want from the pull-down menu below.

<BLOCKQUOTE>
<form name="chapter">
<select name="url" size=5>
<option selected value=" ">Please select chapter . . . </option>
<OPTION VALUE="http://www.xxxxxxx.org/Chapter1.doc" target="_top">Chapter 1</option>
<OPTION VALUE="http://www.xxxxxxx.org/Chapter2.doc" target="_top">Chapter2</option>

etc., etc. etc.

Problem: Despite the target="_top" coding, the content of the imported document is loading into the frame that has the coding text rather than in a new browser page. I am using the same coding multiple places as straight html and they all load as advertised. Only difference here is that the new document is called from within Javascript.

Is there something about Javascript that negates the target="_top" (or target="_parent" -- I tried that, too). I can't find anything about this in multiple Internet searches.

Thanks for the help!

STDestiny
06-14-2003, 04:02 AM
Actually, you need to put the target="top" in the <form> tag, not the <option> tags.

-Andrew

NinjaTurtle
06-14-2003, 05:51 AM
or u can do this:

<Select ... onchange="top.location=this.options[this.selectedIndex].value">
<Option value="123.html?a=b">B</option>
<Option value="345.html?a=c">C</option>
</Select>

i havent try this example... u can try this and see.
u can think about it if u have different of option value.

KenHolle
06-14-2003, 03:31 PM
Andrew's suggestion didn't work, but Ninja Turtle's solution sure did. Thank's for the help from both:thumbsup:

El Jimi
08-11-2005, 01:45 AM
i recently found this javascript redirect script at the javascript source website(javascript.internet.com (http://javascript.internet.com)).

a few months ago i switched from a free .tk domain to a paid .be domain (.be is for belgium) for my website. i had to pay for the hosting as well, so i ended up with two sites with the same content (actually three, but that's another story). i figure many of the visitors of my site are quite bothered by the fact that they have to click on another link to get access to the info i offer. so that's why i put your redirect script on the site to make things easier for the visitors.

the problem is: the .tk frame parents the frame that is used by the webpages themselves. so when i put a redirect script on the pages, everything works great, except that the .be paid domain is loaded in the frame that's underneath the .tk frame. so whichever link to access whichever page is clicked, the visitor is still surfing on the .tk site.

my question is: could someone please add a line to the script so that the site i paid for is loaded in the parent frame?

FYI: www.alibi-ike.tk (http://www.alibi-ike.tk) - www.alibi-ike.be (http://www.alibi-ike.be). the website is in dutch, and it's the official site of a local cover band called Alibi Ike. my third site is already successfully redirected. it originally resided on the servers of a belgian ISP called scarlet. the url is http://home.scarlet.be/~js006607.

the following script is the javascript code as it's embedded in the html code on my websites (that are redirected):

<SCRIPT language="JavaScript">
<!-- Original: Corey (638@gohip.com ) -->
<!-- Web Site: http://six38.tripod.com -->
<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->
<!-- Begin
var start=new Date();
start=Date.parse(start)/1000;
var counts=5;
function CountDown(){
var now=new Date();
now=Date.parse(now)/1000;
var x=parseInt(counts-(now-start),10);
if(document.form1){document.form1.clock.value = x;}
if(x>0){
timerID=setTimeout("CountDown()", 50)
}else{
location.href="http://www.alibi-ike.be"
}
}
// End -->
</SCRIPT>

<SCRIPT language="JavaScript">
<!--
window.setTimeout('CountDown()',50);
-->
</SCRIPT>

<SCRIPT language="JavaScript">
<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com --></SCRIPT>
<CENTER>
<FORM NAME="form1">Je wordt automatisch doorverbonden in <INPUT type="text" name="clock" size="2" value="5"> seconden.</FORM>
</CENTER>

i figure the line of code that i'd really like to see added must be something like this:

top.location.target="_top" or
window.location.target="_top" or
top.location.target="_top" or...

thank you very much in advance!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum