how to open in new window

i have another problem πŸ™
this is my script

<script type="text/JavaScript">
    function first()
    {
        var first = confirm("Are you sure you want to navigate away from this page?");
            if (first)
                window.location = "http://www.yahoo.com.sg"
            else
            window.close;
    }
    function second()
    {
        var second = confirm("Are you sure you want to navigate away from this page?");
        if (second)
            window.location = "http://www.google.com"
        else
            window.close;
    }
</script>


<p><b>Click the following link to enter yahoo</b></p>
<p><a href="javascript:first()" rel="nofollow noreferrer noopener"title="Opens in an external website in a new window">yahoo</a></p>

<p><b>Click the following link to check google</b></p>
<p><a href="javascript:second()" rel="nofollow noreferrer noopener" title="Opens in an external website in a new window">google</a></p>

its doesnt open in a new window.
please i need some help. any suggestion or recommendation?

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

Try window.open. This will open a new window:

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

See also:

Method 2

Use the window.open method and specify _blank as the target:

window.open('http://www.yahoo.com.sg', '_blank');

This will open the page in a new window or a new tab, depending on the user settings in the browser.

If you want it to open in a new popup window always, you can specify a parameter string with width and height for the window. However, most browsers will block such a popup that opens a page from a different domain.

Method 3

If you are opening in a new window, you don’t need to check with the user about navigating away.

function first()
    {
           window.open("http://www.yahoo.com.sg")
    }
    function second()
    {
        window.open"http://www.google.com")
    }


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x