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 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Dec 2010
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Combining Window.Open with an Invoked button

    I've created a single form with multiple buttons. I am now attempting to have a couple of these buttons open a new window when clicked. The new window opens fine but the original browser window keeps opening to an [object Window] page. I believe this is because it is not reading the "return false" correctly but I am not sure how to fix this.

    Code:
    function invoke(btn)
    {
        if(btn == 0) document.Lockdate.action="Button1.php";
        if(btn == 1) document.Lockdate.action="window.open('Button2.php'); return false;"
    
        document.Lockdate.submit(); 
    }
    And then here is the code for the buttons themselves:
    Code:
    <input type="button" value="Button1" onclick="invoke(0)">
    <input type="button" value="Button2" onclick="invoke(1)">

  • #2
    Senior Coder
    Join Date
    Dec 2010
    Posts
    2,396
    Thanks
    12
    Thanked 569 Times in 562 Posts
    Easy enough ... you are returning false from the invoke function, but you are not returning it from the event handler:
    Code:
    <input type="button" value="Button1" onclick="return invoke(0)">
    <input type="button" value="Button2" onclick="return invoke(1)">


  •  

    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
    •