Go Around The Tech Corner…

Tech Tip 20: Easy Pop-up Window with JavaScript

Posted on: February 15, 2009


Pop-up windows are helpful when you have that extra information to give away to your readers. Lots of times they are also used for ads or just to display messages for the user, informing them or alerting them about something. It’s very easy to create these pop-up windows using JavaScript.

All you need is a link or a button for instance, which you can click to trigger the pop-up window. You could also choose to have the pop-up displayed when the page to your website loads or when the user starts to navigate away from the website. The trick is to use to the right command.

In this example, I’ll show you how to create a pop-up which appears when the user clicks on a button. Put the following HTML and JavaScript code in the body of the HTML document:

<FORM METHOD="post">
  <INPUT  TYPE="button" VALUE="Click me!"
  OnClick = "popup = window.open
  ('', 'popup', 'width=100, height=100, resizable=no, scrollbars=no');
  popup.document.write('JavaScript!!');
  return true;">
</FORM>

The popup variable is the name of the window that pops up when the user clicks on the button.

The OnClick function takes care of the rest. Try and see if you can make it work!

– Millie

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Me – The author of this blog!


This is my tech blog. I got another blog, full of jokes that will crack u up! http://humoraddict.blogspot.com

Follow milliepatel84 on Twitter

Tweet Tweet…!!!!

Blog Stats

  • 44,031 hits

Top Clicks

  • None

Flickr Photos

%d bloggers like this: