Asked 3 years ago
19 Nov 2020
Views 760

posted

Window open() Method

how to use window open() method ?
sandip

sandip
answered Nov 30 '-1 00:00

window.open() method opens a new browser window, or a new tab

window.open("https://www.example.com");


code will run and show open new tab with url www.example.com


jassy

jassy
answered Nov 30 '-1 00:00

open() method has the first argument will be URL which you want to open
and the second argument will be the option which decides

window.open("http://www.google.com","_blank");


it will open the new tab or window with the given first argument URL, so it open http://www.google.com in the new tab or window



window.open("http://www.google.com","_self");

it will open in the same tab or window for the given URL as the first argument, it means http://www.google.com in the current tab or window


window.open("http://www.google.com","_parent");

if you running in iframe this code , it will open the http://www.google.com in parent window which host iframe
if still it runs in the parent window, it will work as _self , it will open given url in the current tab or window


window.open("http://www.google.com","_top");

in frameset , one of the child if run above code , it will open given url in the first parent


window.open("https://www.google.com", "", "width=400,height=400");

it open window with height and width 400 , with given url



window.open("", "", "width=400,height=400");

it open blank window with height and width 400


window.open("https://www.google.com", "_blank", "toolbar=yes,scrollbars=yes,resizable=yes,top=200,left=200,width=200,height=200");

we can control the window as many by above parameter ,
Post Answer