How to redirect a user from one webpage to another webpage using Jquery/Javascript?

Introduction

In this article I am going to tell you how to redirect a user from one webpage to another webpage using Jquery or Javascript. For this excercise, you can use any javascript editor

By using window.location

window.location.href = ‘http://www.techstudy.org’

document.location.href = ‘/path-of-the-webpage’

window.location.replace(‘http://www.techstudy.org’)

window.location.assign(‘http://www.techstudy.org’)

By using jQuery

$(location).attr(‘href’,’http://www.techstudy.org’)

$(window).attr(‘location’,’http://www.techstudy.org’)

$(location).prop(‘href’, ‘http://www.techstudy.org’)

Leave a Comment