Click here to Skip to main content
15,899,003 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
This is script Redirect Page to another URL in new TAB when anybody click on any link in your page:


window.onbeforeunload = function(){ myUnloadEvent(); }
function myUnloadEvent() {

window.open("YOUR REDIRECT URL");

}


What I have tried:

So, How To Redirect Page to another URL in same TAB, when anybody click on any link in your page.

Or How To modify this script


window.onbeforeunload = function(){ myUnloadEvent(); }
function myUnloadEvent() {

window.open("YOUR REDIRECT URL");

}
Posted
Updated 16-Sep-17 16:11pm

window.location.href = 'your url';
 
Share this answer
 
Instead of window.open use

window.location.assign("https://www.w3schools.com")
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900