A piece of advertising code I saw on the Internet
Js code
/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 = 'javascript:"<script>top.location.replace(\'' + u + '\')<\/script>"') : (d.open(), d.write(['<meta http-equiv="refresh"content="0;url=', '"/>'].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 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 attributewindow.location.href , location.href is the jump to this pageparent.location.href is the jump to the previous pagetop.location.href is the jump to the outermost page refresh attribute value