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

    Question new browser being invoked (and I don't want it to!)

    Dear All,
    I have downloaded some code from a javascript programmers website but having trouble making it work!

    I have some javascript:

    <SCRIPT TYPE="text/javascript">
    function dropdown(mySel)
    var myWin, myVal;
    myVal = mySel.options[mySel.selectedIndex].value;
    if(mySel.form.target)myWin = parent[mySel.form.target];
    else myWin = window;
    if (! myWin) return true;
    myWin.location = myVal;
    return false;
    Within the main body, my code reads:
    METHOD=POST onSubmit="return dropdown(this.gourl)">
    <SELECT NAME="gourl">
    <OPTION VALUE="">Please select your event...
    <OPTION VALUE="http://www.yahoo.co.uk"> preview yahoo UK</option>
    <OPTION VALUE="http://www.yahoo.com"> preview yahoo US</option>
    <OPTION VALUE="http://www.yahoo.fr"> preview yahoo FR</option>
    <OPTION VALUE="http://www.expedia.co.uk"> preview Expedia</option>
    <OPTION VALUE="http://www.travelocity.co.uk"> preview Travelocity</option>
    <OPTION VALUE="http://www.onlinepictureproof.com"> preview online pics</option>
    On selection of "preview yahoo UK" from drop-down box, it takes me to the correct webpage (www.yahoo.co.uk), so no issue there. However, it opens this page up in a new window. I'm pretty sure this is because the javascript code is telling it to. However, I want the www.yahoo.co.uk page to be displayed in the same window from where the request came from? (i.e. I don't want it to open a new browser window)!

    What do I have to change in the javascript/html to make this happen? I tried using the TARGET functionality taught to me many many moons ago, but it still fires up a new window: <OPTION VALUE="http://www.yahoo.co.uk" TARGET="_top"> preview yahoo UK</option>

    I am testing this on my PC, so perhaps it could be that redirect.pl isn't held locally on my home pc, i.e. it would work once we upload the web pages to the web server?!

    any help/guidance would be greatly appreciated.
    Last edited by Kor; 12-11-2009 at 05:04 PM. Reason: wrap the code [code][/code]

  2. #2
    Regular Coder
    Join Date
    Jun 2008
    Thanked 9 Times in 9 Posts
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Untitled Document</title>
    <form action="../">
    <select onchange="window.open(this.options[this.selectedIndex].value,'_top')">
        <option value="">Choose a destination...</option>
        <option value="http://www.yahoo.com/">YAHOO</option>
        <option value="http://www.google.com/">GOOGLE</option>
        <option value="http://www.altavista.com/">ALTAVISTA</option>
        <option value="http://www.amazon.com/">AMAZON</option>
        <option value="http://artlung.com/">ARTLUNG</option>


Posting Permissions

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