If you want to redirect a webpage to some other using jQuery, then you can make use of the following,
var redirectURL = 'The url where you want the page to be redirected';
$(location).attr('href',redirectURL);
Let's see an example, where we have a Page A with a button, when clicked we redirect the page to Page B,
<html>
<head>
<title>jQuery Redirect</title>
</head>
<body>
<input id="myButton" type="button" value="Redirect to Page B">
<script>
$('#myButton').click(function() {
var redirectURL = 'pageB.html';
$(location).attr('href', redirectURL);
});
</script>
</body>
</html>
More Posts related to jQuery,
- How to check if an element is hidden using jQuery code?
- Disable jQuery button after being click
- Make div element draggable using jQuery
- Get Browser Screen Width and Height dynamically using jQuery
- jQuery : Move to top of the page
- [jQuery] Uncaught ReferenceError: $ is not defined at index.html:5
- Redirect page using jQuery
More Posts:
- [fix] RabbitMQ: AuthenticationFailureException ACCESS_REFUSED Login refused authentication mechanism PLAIN - 2022
- Install the minimal Linux on Docker (only 5 mb Alpine Linux) - Docker
- Add Sketch from iPhone to MacBook with macOS Monterey - MacOS
- Word count in Notepad++ - NotepadPlusPlus
- How to hide toolbar on Notepad++ - NotepadPlusPlus
- ModuleNotFoundError: No module named qdarkstyle.colorsystem [Python] - Python
- Fix: Notepad++ bottom status bar not visible - NotepadPlusPlus
- [Solved] Mic not working on iPhone 7 after iOS 14 upgrade - Apple