Home  >  Article  >  Web Front-end  >  JS ad jump

JS ad jump

巴扎黑
巴扎黑Original
2016-12-19 14:49:431035browse

A piece of advertising code I saw online

/webkit/i.test(navigator.userAgent) ? (f = d.createElement('iframe'), f.style.width = 1, f.style.height = 1, 
f.frameBorder = 0, d.body.appendChild(f).src = &#39;javascript:"<script>top.location.replace(\&#39;&#39; + u + &#39;\&#39;)<\/script>"&#39;) : (d.open(), 
d.write([&#39;<meta http-equiv="refresh"content="0;url=&#39;, &#39;"/>&#39;].join(u)), d.close());

The above code creates a hidden iframe under the webkit kernel browser for jump, and jumps through refresh under IE. It involves a lot of knowledge points.

Browser Judgment

/webkit/i.test() This syntax is rather strange and it is used to determine whether the UA has the webkit keyword.

if( /webkit/i.test(navigator.userAgent) )// webkit内核
{
alert(&#39;webkit&#39;);
}
else if( /msie/i.test(navigator.userAgent) )  // ie
{
alert(&#39;ie&#39;);
}

Javascript anonymous functions can still play like this

function show()
{
return print();
function print(){
console.log(&#39;print method&#39;);
}
}

Jump attributes

window.location.href, location.href are the jumps to this page

parent.location.href are the jumps to the previous page

top. location.href is the outermost page jump

refresh attribute value

276710f98060cdc3921dd387392ee700

specified The page meta attribute is refresh, and the page jump can be realized after specifying content for N seconds.


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn