Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Jun 2003
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Target="_top" not working from within javascript and frames.

    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!

  • #2
    Regular Coder
    Join Date
    May 2003
    Location
    Manassas, VA, USA
    Posts
    220
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Actually, you need to put the target="top" in the <form> tag, not the <option> tags.

    -Andrew

  • #3
    Regular Coder
    Join Date
    Jun 2002
    Posts
    358
    Thanks
    2
    Thanked 0 Times in 0 Posts
    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.
    Thanks.
    =====================================================
    From NinjaTurtle
    ++http://ohmygoh.blogspot.com|http://technology.ohmygoh.com++

  • #4
    New to the CF scene
    Join Date
    Jun 2003
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Beauty!!

    Andrew's suggestion didn't work, but Ninja Turtle's solution sure did. Thank's for the help from both

  • #5
    New to the CF scene
    Join Date
    Aug 2005
    Location
    Belgium
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question

    i recently found this javascript redirect script at the javascript source website(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 - 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!
    Last edited by El Jimi; 08-11-2005 at 01:53 AM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •