...

View Full Version : Would like help with getting a window.open function to work!



APD1993
03-02-2012, 11:29 AM
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:




function ValidateWebDetails
{
window.open("faqs.html")
}

To test whether the function actually worked, I first attached it to a button with this 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! :D

jalarie
03-02-2012, 02:34 PM
I think you need a semi-colon (;) on your button line and, definitely, a closing gtreater-than (>) sign:


<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:


PopUp=window.open("faqs.html");


You may need a name for the pop-up window, but I'm not positive about that:


PopUp=window.open("faqs.html","Name");

ckeyrouz
03-02-2012, 03:14 PM
As I see you have two problems.
1- You need to close the tag input



<input type="button" value="Go To FAQS" onClick="ValidateWebDetails()" />


2- When you declare a javascript function you need to add the parenthesis like this


function ValidateWebDetails()
{
window.open("faqs.html");
}



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum