To open a window using JavaScript, use window.open. Depending on how you have your browswer options configured, the "pop-up" might open in a new tab instead of in a new window.
The command has optional parameters:
1st parameter: location (web page to load in the new window)
2nd parameter: window name
3rd parameter: one or more optional strings indicating the desired window width, height, and indicating whether you want the window to contain an address bar, scroll bar, etc.
If you want to specify a window name, but don't want to specify a location, you must still include an empty first parameter as a placeholder.
Output:
I created the following pop-up and pop-under windows, they contain no advertising or malicious code:Code:
<script type="text/javascript"> //<![CDATA[
window.name="main"; function createPopup(url) { var myNewPopUp = window.open(url, 'window2', 'width=700,height=400,scrollbars=yes,status'); myNewPopUp.focus(); return false; } function createPopunder(url) { var myNewPopUnder = window.open(url, 'window3', 'width=300,scrollbars=yes,height=150'); myNewPopUnder.blur(); return false; } //]]> </script> </span> <span class="body-copy">I created the following pop-up and pop-under windows, they contain no advertising or malicious code:</span><br><br> <a href="popup.htm" onclick="return createPopup('popup.htm')">Click here to open a pop-up.</a><br><br> <a href="popunder.htm" onclick="return createPopunder('popunder.htm')">Click here to open a pop-under, that is, a window hidden under the main window.</a><br>