How to open new window and how to make popup windows using javascript

Making of popup windows and how to open new browser window of a new url


Category: Java Script Tags: HTML, Java Script


Java Script tutorial 12

        Today I am going to show you how to make such a popup window or how to open new window
using javascript if client clicks on a control like image.

<html>
<head>
<script type="text/javascript">
var newWindow;
function change(URL)
{
newWindow = window.open(URL, "Dotnetlovers",
"width=800,height=350,scrollbars=1");
newWindow.focus();
}
</script>
</head>
<body>
<h2>Dotnetlovers</h2>
<p>Dotnetlovers is a good website for learn any type of coding techniques.</p>
<p>
<h4>Click below on logo of Dotnetlovers:</h4>
<img src="dotnetlovers.png" alt="Professional Ajax, 2nd Edition" border="0"
onclick="change('default.aspx')" />
</p>
</body>
</html>

        Here in above code we created an image control and onclick event bounded with function change() with parameter URL of page which we wanted to open. In the function we created variable newWindow which gets the identity of new opened window. We use here window.open with three arguments, first is URL of window to be opened and second is a small description or may be title of that window and third is a group of characteristics of new window like width, height, scrollbars, resizable, location, menu-bar etc.


Like 1 Person
Last modified on 29 August 2018
Nikhil Joshi

Nikhil Joshi
Ceo & Founder at Dotnetlovers
Atricles: 133
Questions: 9
Given Best Solutions: 9 *

Comments:


You are not loggedin, please login or signup to add comments:

Existing User

Login via:

New User



x