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 3 of 3
  1. #1
    New Coder
    Join Date
    Mar 2012
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Would like help with getting a window.open function to work!

    I am making a website where when the user clicks on a hyperlink in a list, a new browser window opens and displays a file called "faqs.html".

    The code for my function so far is:

    Code:
    function ValidateWebDetails
    {
    	window.open("faqs.html")
    }
    To test whether the function actually worked, I first attached it to a button with this code:

    Code:
    <form method="post">
     <input type="button" value="Go To FAQS" onClick="ValidateWebDetails()"
     </form>


    However, when I went to test the button, when I clicked on it, no new window was displayed and I was wondering what I could do to fix the problem.

    Any help is appreciated!

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Location
    Flint, Michigan, USA
    Posts
    629
    Thanks
    1
    Thanked 20 Times in 20 Posts
    I think you need a semi-colon (;) on your button line and, definitely, a closing gtreater-than (>) sign:
    Code:
    <input type="button" value="Go To FAQS" onClick="ValidateWebDetails();">
    Also, I usually specify a variable to hold a reference to the pop-up so that I can reference it later if I wish:
    Code:
    PopUp=window.open("faqs.html");
    You may need a name for the pop-up window, but I'm not positive about that:
    Code:
    PopUp=window.open("faqs.html","Name");

  • #3
    Senior Coder ckeyrouz's Avatar
    Join Date
    Jun 2009
    Location
    Montreal, Canada
    Posts
    1,044
    Thanks
    5
    Thanked 179 Times in 179 Posts
    As I see you have two problems.
    1- You need to close the tag input

    Code:
    <input type="button" value="Go To FAQS" onClick="ValidateWebDetails()" />
    2- When you declare a javascript function you need to add the parenthesis like this
    Code:
    function ValidateWebDetails()
    {
    	window.open("faqs.html");
    }
    Software and cathedrals are much the same - first we build them, then we pray.


  •  

    Posting Permissions

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