How to make a page redirect in Java Script?

The simplest way to make a redirect is by using window object (window.location.href):

window.location.href = 'http://mysite.com';

You also can use window.location.assign or window.location.replace:

window.location.assign( 'http://mysite.com' );

window.location.replace( 'http://mysite.com' );

While window.location.assign acts just like window.location.href, window.location.replace doesn't store original page in browser history.

Continue reading here: How to create a simple CSS gallery without using Java Script

Was this article helpful?

0 0