Click to See Complete Forum and Search --> : Pop Up Window
endrezults
11-17-2003, 02:49 PM
Hi,
I want to create a pop up window that is loaded when I click on a link. I'm not exactly sure how to do this although I think its relatively simple. Can someone please help me?
Thanks in advance!
fredmv
11-17-2003, 02:52 PM
Welcome to the forums.
Please check this FAQ (http://webdevfaqs.com/javascript.php#centeredpopup).
Good luck.
Charles
11-17-2003, 03:19 PM
You don't need to make it all that complicated. For a simple popup just use
<a href="http://www.w3.org/" onclick="window.open(this.href, 'height=300,width=200'); return false">W3C</a>
But if you want scrollbars use
<a href="http://www.w3.org/" onclick="window.open(this.href, 'height=300,width=200,scrollbars'); return false">W3C</a>
And see http://devedge.netscape.com/library/manuals/2000/javascript/1.3/reference/window.html#1202731 for the official details.
fredmv
11-17-2003, 03:25 PM
Originally posted by Charles
You don't need to make it all that complicated.I agree with you. However, I figured the sole purpose of those FAQs were to cut down on common/simple questions like this, that's why I referred the orignal poster to it. Also, just to note, you have a slight syntax error. The order of arguments in the open method is:
window.open([String URL], [String NAME], [String FEATURES]);
Since you didn't include a name for the new window, as a result, your features will not be applied to the new window. It should be as simple as this:
<a href="http://www.w3.org/" onclick="window.open(this.href, 'foo', 'height=300,width=200,scrollbars'); return false">W3C</a>
I would also like to point out that opening new windows should always be avoided when possible and used only when the only possible solution (which isn't very likely), as it destroys accessibility (http://www.diveintoaccessibility.org/day_16_not_opening_new_windows.html).
Charles
11-17-2003, 03:36 PM
Thanks for catching that syntax error.
I'm not so down on the use of pop up windows as some other people. They have their uses. I hate them myself, so I protect myself. I disable pop up and JavaScript when I surf. As long as the web author uses a method that transitions well, then everybody can be happy.
fredmv
11-17-2003, 03:38 PM
No problem Charles, just trying to help out. As for your comments, I completely agree. I have JavaScript enabled, however, my browser (Mozilla Firebird) blocks unrequested pop-up windows by default though.