SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    The Jellophonic Autobrain CHeeSeBLiND's Avatar
    Join Date
    Jul 2001
    Location
    Bolton, England
    Posts
    584
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    open links in new window

    can anyone help me with this script?

    i need a script that allows users to check a checkbox. when the box is checked the links will open in new windows when its unchecked itll open in the same window
    hmm...

  2. #2
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,235
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Ok let's assume your checkbox is named "check1" and your form is named "form1". This will open the link in a new window when check1 is checked upon submitting the form.
    Code:
    <head>
    <script language="javascript" type="text/javascript">
    function changeTarget(frm, cBox) {
     if(cBox.checked){
      frm.target = "_blank";
     }
    }
    </script>
    </head>
    <body>
    <form name="form1" action="yourpage.asp" onsubmit="changeTarget(this, this.check1);">
    <input type="checkbox" name="check1" /><br />
    <input type="submit" name="Submit" value="Submit Form" />
    </form>
    Hope this helps!

    --Vinnie

  3. #3
    SitePoint Wizard Bill Posters's Avatar
    Join Date
    Dec 2001
    Location
    UK
    Posts
    1,523
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you're after something more general, see this article at Evolt.org.

    This article is by the script author and discusses in depth the various aspects of its use.


    For a lazy, quick how-to, find out simply How to Open links in a New Window using a checkbox setting.
    It's the same basic script, but was posted at javascript.internet.com without the author's permission (or his notes).
    Last edited by Bill Posters; Nov 6, 2002 at 15:52.
    New Plastic Arts: Visual Communication | DesignateOnline

    Mate went to NY and all he got me was this lousy signature


Bookmarks

Posting Permissions

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