Is it possible to redirect my website visitor from one page to another using JQuery?
and how can i do that?
thanks!
Is it possible to redirect my website visitor from one page to another using JQuery?
and how can i do that?
thanks!
I don’t think you will have to use any JQuery at all.
there are two methods to redirect from a page to another using javascript alone:
document.location.href
:document.location.href = "Your new page url";
document.location.href
will cause for that HTTP request to be listed in the session history for your browser as an explicit request. meaning that it will be visible when user clicks (back and forward) buttons and that might cause some unwanted confusion for the visitor.document.location.replace()
:document.location.replace("Your new page url");
In your case i think you should go with document.location.replace()
as that will make an internal redirect without confusing the visitors of your website.
document.location.replace("http://stopbyte.com");
If JQuery is required, you can do it this way:
$(location).attr('href', 'http://stopbyte.com')
But it’s highly recommended that you use the Javascript pure solution suggested by @isoftech .