www.webdeveloper.com
Results 1 to 10 of 10

Thread: How to create a checkbox that will open a website in a new window

  1. #1
    Join Date
    Feb 2011
    Posts
    8

    How to create a checkbox that will open a website in a new window

    I want to know how to create a check box that will load websites in a new window. Thanks for any help that you can give.

  2. #2
    Join Date
    Dec 2005
    Location
    FL
    Posts
    7,435

    Talking Something to try ...

    Something like this ...
    Code:
    <html>
    <head>
    <title> Untitled </title>
    <script type="text/javascript">
    // From: http://www.webdeveloper.com/forum/showthread.php?t=242793
    
    function OpenWindow(info) {
      window.open(info,'WinName','height=400,width=600,resizable=yes,scrollbars=yes');
    }
    </script>
    </head>
    <body>
    
    <input type="checkbox" name="CBox0" value="http://www.webdeveloper.com" 
     onclick="if(this.checked){OpenWindow(this.value)}"> Webdeveloper
    <br>
    <input type="checkbox" name="CBox1" value="http://www.google.com" 
      onclick="if(this.checked){OpenWindow(this.value)}"> Google
    
    </body>
    </html>

  3. #3
    Join Date
    Feb 2011
    Posts
    8
    Cool. Thanks. How do you reload it to another page when it is unchecked?

  4. #4
    Join Date
    Dec 2005
    Location
    FL
    Posts
    7,435

    Lightbulb

    Quote Originally Posted by RainAway View Post
    Cool. Thanks. How do you reload it to another page when it is unchecked?
    How are you going to use this?
    Clicking a checkbox on/off to show a page doesn't make a lot of sense to me.
    Would be easier just to program a link and not worry about checkbox status.

    But if you really think you need this function, then try ...
    Code:
    <html>
    <head>
    <title> Checkbox Redirect</title>
    <script type="text/javascript">
    // From: http://www.webdeveloper.com/forum/showthread.php?t=242793
    
    function OpenWindow(info) {
      window.open(info,'WinName','height=400,width=600,resizable=yes,scrollbars=yes');
    }
    </script>
    </head>
    <body>
    
    <input type="checkbox" name="CBox0" value="http://www.webdeveloper.com" 
     onclick="if(this.checked){OpenWindow(this.value)}else{OpenWindow('http://www.webdeveloper.com/forum/forumdisplay.php?f=3&order=desc&daysprune=30')}"
     > Webdeveloper / Javascript
    <br>
    <input type="checkbox" name="CBox1" value="http://www.google.com" 
     onclick="if(this.checked){OpenWindow(this.value)}else{OpenWindow('http://www.codingforums.com/forumdisplay.php?f=2')}"
     > Google / CodeingForums
    
    </body>
    </html>

  5. #5
    Join Date
    Feb 2011
    Posts
    8
    It is for a class and the assignment requires it. However, I don't think we need it and my entire class is stuck. I tried different ways and I got it to work with a button and a check box.

  6. #6
    Join Date
    Dec 2005
    Location
    FL
    Posts
    7,435

    Arrow

    Quote Originally Posted by RainAway View Post
    I want to know how to create a check box that will load websites in a new window. Thanks for any help that you can give.
    Quote Originally Posted by RainAway View Post
    It is for a class and the assignment requires it. However, I don't think we need it and my entire class is stuck. I tried different ways and I got it to work with a button and a check box.
    Funny class if you are allowed to change the requirements specified in original post

  7. #7
    Join Date
    Feb 2011
    Posts
    8
    Here is what the book says for the assignment:

    Create a web page with a list of your favorite links. At the top of the page, include a check box with the text "Open link in a new window." If a user click the check box then the links of the page should open in a new window. Otherwise the links should be loaded into current window.

    I dont think this is the best method.

  8. #8
    Join Date
    Feb 2011
    Posts
    8
    Quote Originally Posted by JMRKER View Post
    Funny class if you are allowed to change the requirements specified in original post
    That is why I am confused and so is the rest of my class.

  9. #9
    Join Date
    Dec 2005
    Location
    FL
    Posts
    7,435

    Exclamation

    Quote Originally Posted by RainAway View Post
    That is why I am confused and so is the rest of my class.
    Then you should contact the instructor and request further clarification for both you and the class.

    In the real world you would never design a process without fully understanding the requirements of the process

  10. #10
    Join Date
    Feb 2011
    Posts
    8
    She hasn't replied at all for most of the students questions and I sent her my question today. I think she is still sick and hasn't replied.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

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



Recent Articles