Wednesday, December 21, 2011

Pop-up windows (with a little help from JavaScript)

Wouldn't it be nice to pop-up a little window from your web pages to display messages once in a while (rather than jumping to another page)?
Well, it's very easy to do using JavaScript. First, click on the following button to see an example of our pop-up window:
Now, let's look at the code behind the above button:
<FORM METHOD="post">

<INPUT TYPE="button" VALUE="Click me!"

OnClick = "hint_wnd = window.open(
'', 'hint_wnd', 'width=50, height=60, resizable=no, scrollbars=no' );

hint_wnd.document.write( 'Hello there!' );
return true;">

</FORM>
As you can see, we simply use the "OnClick" event open a window named "hint_wnd," and finally write the string "Hello, there!" to the "hint_wnd" window.

0 comments:

Post a Comment

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | Best Web Hosting