Opening New Windows/Tabs

Discussion in 'Javascript' started by d4rkn1ght, Nov 18, 2006.

  1. d4rkn1ght

    d4rkn1ght Guest

    Hello!

    How can I make this script I generated with HomeSite, open links in new
    windows/tab instead of the same?


    <script language="JavaScript" type="text/javascript">
    <!--
    // original code by Bill Trefzger 12/12/96
    function go1(){
    if
    (document.selecter1.select1.options[document.selecter1.select1.selectedIndex
    ].value != "none") {
    location =
    document.selecter1.select1.options[document.selecter1.select1.selectedIndex]
    ..value
    }
    }
    //-->
    </script>
    <script language="JavaScript" type="text/javascript">
    <!--
    document.write('<form name="selecter1"><select name="select1" size=1>');
    document.write('<option value=none>Test');
    document.write('<option value=none>--------------------');
    document.write('<option value="http://www.a.null">A');
    document.write('<option value="http://www.b.null">B');
    document.write('<option value="http://www.c.null">C');
    document.write('<option value="http://www.d.null">D');
    document.write('</select>');
    document.write('<input type="button" value="Go" onclick="go1()">');
    document.write('</form>');
    // end hiding contents -->
    </script>


    I will like to keep this as simple as possible. I don't know anything about
    JavaScript.


    TIA


    --
    http://www.3macsandaprinter.uni.cc/
    d4rkn1ght, Nov 18, 2006
    #1
    1. Advertising

  2. d4rkn1ght

    ASM Guest

    d4rkn1ght a écrit :
    > Hello!
    >
    > How can I make this script I generated with HomeSite, open links in new
    > windows/tab instead of the same?
    >
    >
    > <script type="text/javascript">


    var truc = false;

    function go1(){
    var S = document.selecter1.select1;
    if(S && S.options[S.selectedIndex].value != "none") {
    url = S.options[S.selectedIndex].value
    if(!truc || truc.closed)
    truc = window.open('','','width=700,height=550,resizable=1');
    truc.location = url;
    truc.focus();
    }
    }

    > </script>
    > <script type="text/javascript">
    > <!--
    > document.write('<form name="selecter1"><select name="select1" size=1>');
    > document.write('<option value=none>Test');
    > document.write('<option value=none>--------------------');
    > document.write('<option value="http://www.a.null">A');
    > document.write('<option value="http://www.b.null">B');
    > document.write('<option value="http://www.c.null">C');
    > document.write('<option value="http://www.d.null">D');
    > document.write('</select>');
    > document.write('<input type="button" value="Go" onclick="go1()">');
    > document.write('</form>');
    > // end hiding contents -->
    > </script>




    --
    Stephane Moriaux et son (moins) vieux Mac déjà dépassé
    Stephane Moriaux and his (less) old Mac already out of date
    ASM, Nov 18, 2006
    #2
    1. Advertising

  3. d4rkn1ght

    d4rkn1ght Guest

    in article 455f9a5d$0$25935$, ASM at
    d wrote on 11/18/06 6:42 PM:

    > d4rkn1ght a écrit :
    >> Hello!
    >>
    >> How can I make this script I generated with HomeSite, open links in new
    >> windows/tab instead of the same?
    >>
    >>
    >> <script type="text/javascript">

    >
    > var truc = false;
    >
    > function go1(){
    > var S = document.selecter1.select1;
    > if(S && S.options[S.selectedIndex].value != "none") {
    > url = S.options[S.selectedIndex].value
    > if(!truc || truc.closed)
    > truc = window.open('','','width=700,height=550,resizable=1');
    > truc.location = url;
    > truc.focus();
    > }
    > }
    >
    >> </script>
    >> <script type="text/javascript">
    >> <!--
    >> document.write('<form name="selecter1"><select name="select1" size=1>');
    >> document.write('<option value=none>Test');
    >> document.write('<option value=none>--------------------');
    >> document.write('<option value="http://www.a.null">A');
    >> document.write('<option value="http://www.b.null">B');
    >> document.write('<option value="http://www.c.null">C');
    >> document.write('<option value="http://www.d.null">D');
    >> document.write('</select>');
    >> document.write('<input type="button" value="Go" onclick="go1()">');
    >> document.write('</form>');
    >> // end hiding contents -->
    >> </script>

    >
    >


    Hey thanks!

    But I was looking for a new browser window/tab not a pop-up window.
    Something more like the (target="_blank") in regular links.

    Can that be possible?


    TIA


    --
    http://www.3macsandaprinter.uni.cc/
    d4rkn1ght, Nov 19, 2006
    #3
  4. d4rkn1ght

    ASM Guest

    d4rkn1ght a écrit :
    >
    > Something more like the (target="_blank") in regular links.


    <script type="text/javascript">
    function go1(){
    var f = document.selecter1;
    var s = f.select1;
    var k = s.selectedIndex;
    if(k>1) {
    f.action=s.options[k].value;
    f.submit();
    }
    }
    </script>
    <script type="text/javascript">
    <!--
    document.write('<form name="selecter1" action="" target="_blank">'+
    '<select name="select1" size=1>');
    document.write('<option value=none>Test');
    document.write('<option value=none>--------------------');
    document.write('<option value="test.htm">A');
    document.write('<option value="test_1.htm">B');
    document.write('<option value="http://www.c.null">C');
    document.write('<option value="http://www.d.null">D');
    document.write('<\/select>');
    document.write('<input type="button" value="Go" onclick="go1()">');
    document.write('<\/form>');
    // end hiding contents -->
    </script>


    --
    Stephane Moriaux et son (moins) vieux Mac déjà dépassé
    Stephane Moriaux and his (less) old Mac already out of date
    ASM, Nov 19, 2006
    #4
  5. d4rkn1ght

    d4rkn1ght Guest

    in article 455fb5b7$0$5076$, ASM at
    d wrote on 11/18/06 8:39 PM:

    > d4rkn1ght a écrit :
    >>
    >> Something more like the (target="_blank") in regular links.

    >
    > <script type="text/javascript">
    > function go1(){
    > var f = document.selecter1;
    > var s = f.select1;
    > var k = s.selectedIndex;
    > if(k>1) {
    > f.action=s.options[k].value;
    > f.submit();
    > }
    > }
    > </script>
    > <script type="text/javascript">
    > <!--
    > document.write('<form name="selecter1" action="" target="_blank">'+
    > '<select name="select1" size=1>');
    > document.write('<option value=none>Test');
    > document.write('<option value=none>--------------------');
    > document.write('<option value="test.htm">A');
    > document.write('<option value="test_1.htm">B');
    > document.write('<option value="http://www.c.null">C');
    > document.write('<option value="http://www.d.null">D');
    > document.write('<\/select>');
    > document.write('<input type="button" value="Go" onclick="go1()">');
    > document.write('<\/form>');
    > // end hiding contents -->
    > </script>
    >


    It works! Thank you very much!


    --
    http://www.3macsandaprinter.uni.cc/
    d4rkn1ght, Nov 19, 2006
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. qwweeeit
    Replies:
    2
    Views:
    646
    qwweeeit
    Dec 14, 2005
  2. Matt

    Counting Tabs, New lines, etc. ~error~

    Matt, Apr 20, 2005, in forum: C Programming
    Replies:
    4
    Views:
    384
    Old Wolf
    Apr 20, 2005
  3. rantingrick

    Tabs -vs- Spaces: Tabs should have won.

    rantingrick, Jul 16, 2011, in forum: Python
    Replies:
    95
    Views:
    1,831
    Roy Smith
    Jul 19, 2011
  4. John Kopanas
    Replies:
    2
    Views:
    287
    Gregory Brown
    Jan 29, 2007
  5. Andrew Poulos

    browser opens new windows or tabs

    Andrew Poulos, Feb 16, 2008, in forum: Javascript
    Replies:
    11
    Views:
    158
    Joost Diepenmaat
    Feb 22, 2008
Loading...

Share This Page