How to Prevent window.open from focusing on new tab open

Ever you tried open new tab on page load and don't want to browser focuse on newly opend tab, well this trick will help you to achive this.

 
   var url = 'https://www.webtutorial.in';
   var myWindow = window.open(url,name,'_blank');
window.open().close();

If you want to use this code on page load you can to it like this.

first set this

<body onload="red()">

then put this code anywhere you want on page but inside <body> {your code}</body> tag

<script type="text/javascript">
 function red(){
   var url = 'https://www.webtutorial.in';
   var myWindow = window.open(url,name,'_blank');
window.open().close();
   }
</script>

this code will open new tab and send to background.

Thank you.

Other posts