Definition and Usage..
The open() method opens a new browser window.
Tip: Use the close() method to close the window.
Return Value:A reference to the newly created window, or null if the call failed
Syntax : window.open(URL, name, specs, replace)
Differents way how to declare open() in program.
CODING:The open() method opens a new browser window.
Tip: Use the close() method to close the window.
Return Value:A reference to the newly created window, or null if the call failed
Syntax : window.open(URL, name, specs, replace)
Differents way how to declare open() in program.
<!DOCTYPE html>
<html>
<body>
<p>Click the button to open a new browser window.</p>
<button onclick="Fun1()">Open Window</button>
<p>Click the button to open a new window called "MsgWindow" with some text.</p>
<button onclick="Fun2()">Open Window</button>
<p>Replace the current window with a new window:</p>
<button onclick="Fun3()">Open Window</button>
</p>Open a new window called "MsgWindow", and write some text into it:</p>
<button onclick="Fun4()">Open Window</button>
<script>
function Fun1() {
window.open("http://cprogramaboutexample.blogspot.in");
}
function Fun2() {
var nwWindow1 = window.open("", "MsgWindow", "width=200,height=100");
nwWindow1.document.write("<h1>Hi I am New Window!</h1>");
}
function Fun3() {
var newWidow2 = window.open("", "_self");
newWidow2.document.write("<p>I replaced the current window.</p>");
}
function Fun4() {
window.open("http://cprogramaboutexample.blogspot.in", "_blank","toolbar=yes,scrollbars=yes,resizable=yes,top=500,left=500,width=400,height=400");
}
</script>
</body>
</html>
<html>
<body>
<p>Click the button to open a new browser window.</p>
<button onclick="Fun1()">Open Window</button>
<p>Click the button to open a new window called "MsgWindow" with some text.</p>
<button onclick="Fun2()">Open Window</button>
<p>Replace the current window with a new window:</p>
<button onclick="Fun3()">Open Window</button>
</p>Open a new window called "MsgWindow", and write some text into it:</p>
<button onclick="Fun4()">Open Window</button>
<script>
function Fun1() {
window.open("http://cprogramaboutexample.blogspot.in");
}
function Fun2() {
var nwWindow1 = window.open("", "MsgWindow", "width=200,height=100");
nwWindow1.document.write("<h1>Hi I am New Window!</h1>");
}
function Fun3() {
var newWidow2 = window.open("", "_self");
newWidow2.document.write("<p>I replaced the current window.</p>");
}
function Fun4() {
window.open("http://cprogramaboutexample.blogspot.in", "_blank","toolbar=yes,scrollbars=yes,resizable=yes,top=500,left=500,width=400,height=400");
}
</script>
</body>
</html>
Comments
Post a Comment