A new way for js to pop up new pages to avoid being blocked by browsers and AD

  • 2020-03-30 02:46:38
  • OfStack

Bind the click popover to a normal link, a[target=_blank], and modify its href before clicking to open the new window.

Bind the mousedown and mouse click to modify the href before execution.

Bind focus to ensure that href is replaced when TAB +enter is switched.
<input type="search" id="keyword" value="" autocomplete="off" placeholder=" Please enter the search keyword " /> 
<a href="###" id="submit" target="_blank" > search </a> 
<script type="text/javascript"> 
(function(document) { 
var submit = document.getElementById('submit'); 
var keyword = document.getElementById('keyword'); 
var url = 'http://www.baidu.com/baidu?wd='; 
submit.onfocus = submit.onmousedown = function() { 
var href = url + escape(keyword.value); 
if (href !== submit.href) { 
submit.href = url + escape(keyword.value) 


Ps: you can also bind in HTML code with onclick dom level 0, submit forms with target, etc

Related articles: