JavaScript open URL in a modal window | Example code

  • by

Use the window open() method to popup a window tab as a modal with a URL.

Note: JavaScript already has the ShowModalDialog function but it does not work in all browsers.

JavaScript open URL in a modal window Example

HTML example code:



		var popUpObj;

		function showModalPopUp(){"PopUp.htm","ModalPopUp","width=400," + "height=300");





	<input id="Button1" type="button" value="button" onclick="showModalPopUp()" />


JavaScript open URL in a modal window

More parameters can use in the

You can freeze the parent window and when the popup is closed the parent window is changed back to normal."PopUp.htm",

			"toolbar=no," +

			"scrollbars=no," +

			"location=no," +

			"statusbar=no," +

			"menubar=no," +

			"resizable=0," +

			"width=400," +

			"height=300," +

			"left = 490," +



Do comment if you have any doubts and suggestions on this JS URL tutorial.

Note: The All JS Examples codes are tested on the Firefox browser and the Chrome browser.

OS: Windows 10

Code: HTML 5 Version

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.