Home > Web Front-end > JS Tutorial > body text

JS ad jump

巴扎黑
Release: 2016-12-10 09:07:43
Original
1704 people have browsed it

A piece of advertising code I saw on the Internet

Js code

/webkit/i.test(navigator.userAgent) ? (f = d.createElement(&#39;iframe&#39;), 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());
Copy after login

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 of.

Browser Judgment

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

Js code

if( /webkit/i.test(navigator.userAgent) )// webkit kernel

{

alert('webkit');

}

else if( /msie/i .test(navigator.userAgent) ) // ie

{

alert('ie');

}

Javascript anonymous functions can still play like this

Js code

function show ()

{

  return print();

  function print(){

              console.log('print method');

Jump attribute

window.location.href , location.href is the jump to this page

parent.location.href is the jump to the previous page

top.location.href is the jump to the outermost page

refresh attribute value

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!