Javascript popup and window methods

Javascript popup and window methods
----------------------------------------------

Javascript popup and window methods

We use window popups very often to show additional information to users.

Basically to run we use the below code

window.open('https://coderuck.com');

So if you run it will open a new window with the given URL

An important point to note is that most modern browsers block the popup unless it is triggered by the user on a specific event like onClick.

Now if we take an example when the user clicks a button at that point we have to open the popup

button.onClick = () =>{
    window.open('http://coderuck.com');
} 

If we take another example which can be blocked by the browser

window.open('https://coderuck.com');

and the reason why most modern browser block popup is because the previous website uses popups a lot.To show ads and content which is not relevant to the user.
Because to protect the user it is sometimes blocked by the browser.

Syntax

window.open(url,name,options);

url: An URL to open.
name:A name of the new window.
options: Various configurations can be used using comma separated like width=100,height=100,resizable=no
there are lots of other options which users can use and also it depends upon the browser.  

Categories: Java Script Tags: #JavaScript,

Newsletter Subcribe

Receive updates and latest news direct from our team. Simply enter your email.