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)