You are here: Home // Programming // How to open Modal window in Javascript

How to open Modal window in Javascript

Sometimes we need to show Modal window in our web application. This window basically opens a popup window which does not allow the user to click any link in the background. User will be able to click on the background when he/she closes the window. The code snippet is given below:


  1. <script anguage=“JavaScript”> function openWindow()
  2. {
  3. var myArguments = ‘nothing’; window.showModalDialog(”http://www.google.com”, myArguments, ”);
  4. }
  5. </script>
  6. <button onclick=“openWindow();”>Click Here</button> </body>
  7. </html>
Blog Widget by LinkWithin

No related posts.

Tags: , , , ,

3 Responses to " How to open Modal window in Javascript "

  1. [...] Continued here: How to open Modal window in Javascript | TechCuBeTalk [...]

  2. Badotz says:

    Is “window.showModalDialog” browser-neutral?

  3. admin says:

    The window.showModalDialog feature was not added to Firefox until version 3.0 https://developer.mozilla.org/en/DOM/window.showModalDialog

    so it won’t work if you use this javascript in old browser. I don’t have any idea if it works or not in Chrome? Any idea Badotz?

Leave a Reply

Spam Protection by WP-SpamFree

Copyright © 2009 TechCuBeTalk free technology magazine. All rights reserved.
Designed by Theme Junkie. Powered by WordPress.