Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to open another page with button click in jQuery?

    • 0
    • 1
    • 0
    • 1
    • 0
    • 0
    • 0
    • 0
    • 377
    Comment on it

    Sometimes we need to open another page on button click.

    We can do this in tow ways either by using "window.location" or "window.open()".

    Example: In the below example I have put conditions on "blur" event for checking whether the input field is empty or not and also put condition on "focus" event to remove the error message when the particular input field gets focus.

    <input type="button" value="Search" onClick="openPage();"/>
    
    function openPage()
    {
        var url = "logout";// write here the url you want to open
        var win = window.open(url, '_self');// it will open page in the same tab
        //var win = window.open(url, '_blank');// it will open page in new tab
        win.focus();
    }
    

    or

    function openPage()
    {
        var url = "logout";// write here the url you want to open
        window.location = "logout";//it will open page in the same tab
    }
    

    Hope this will help you :)

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: