spot_img

How to Redirect a Webpage using jQuery?

Redirecting a user from one page to another, or even from your website to another, maybe accomplished in a variety of ways.

We’ll go through how to achieve this operation utilizing the jQuery library as well as pure JavaScript in this tutorial.

How to redirect to another page using jQuery?

Using jQuery to redirect a visitor to a different website is a simple one-liner.

Remember that this solution relies on the jQuery library, so make sure it’s installed before running the code. For this reason, the second solution is given above, which uses pure JavaScript, is preferable.

jQuery Solution

$(location).attr('href','http://google.com');

Let’s take a look at the vanilla JavaScript version, which is slightly different but preferable.

How to Redirect a Webpage using Pure Javascript?

The vanilla JavaScript version of this code is also a simple one-liner.

window.location.href = "http://google.com";

It’s as simple as that. You now know how to use jQuery to redirect a webpage. Unless you’re dead set on using jQuery, opt for the second pure JavaScript solution.

spot_img

Subscribe

Related articles

OnePlus 5T Wallpapers Download

Introduction: The OnePlus 5T is a popular smartphone known for...

Airtel’s First Quarterly Loss in 2002: A Closer Look at Jio’s Impact

The telecom industry has witnessed several significant shifts over...

Xiaomi Confirms Investment in Blackshark Gaming Phone Launch set for April 13

An engaging introduction to Xiaomi Confirms Investment in Blackshark...

LG G7 ThinQ M LCD Panel

Introduction:The LG G7 ThinQ M LCD panel is a...

Intel Core i9 Laptops with Optane Memory

Intel Core i9 laptops with Optane Memory combine the...

Apple iOS 11.4 Beta 1

Apple iOS 11.4 Beta 1 is the latest update...

Google Search AI Reorganization: Improving Search Quality and User Experience

Introduction:In the ever-evolving digital landscape, search engines play a...
Peter Graham
Peter Grahamhttp://fix-iphones.com
Hi there! I'm Peter, a software engineer and tech enthusiast with over 10 years of experience in the field. I have a passion for sharing my knowledge and helping others understand the latest developments in the tech world. When I'm not coding, you can find me hiking or trying out the latest gadgets.

LEAVE A REPLY

Please enter your comment!
Please enter your name here