一个博客

包含「window」标签的文章

共找到3个结果

  • window.open被拦截

    首先我们都知道,只要是用户行为触发的打开新窗口的操作是不会被浏览器拦截的,比如 onclick 的时候,onchange 的时候打开一个新窗口,没问题。但是浏览器判定事件源的感知时间是不是无限的(1s,延迟1s 的 open 操作都会被拦截,来源:http://hi.barretlee.com/2014/09/07/onclick-in-javascript/),所以在...

  • window.name实现跨域

    为什么是window.name?而不是window.status或者其他的普通变量? window.name 的美妙之处:name 值在不同的页面(甚至不同域名)加载后依旧存在,并且可以支持非常长的 name 值(2MB)。明白了这个问题之后,来看看window.name怎么跨域?原理其实很简单,就是内嵌一个异域的iframe,onload完之后将iframe的location改成一个本域的location,(不是更改iframe的src)然后获取异域iframe中的window.name的值,(虽然同域了,不过iframe中的name属性还存在)紧接着摧毁iframe,释放内存。这里有几个得注意的地方:...

  • 从重写全局函数window说起

    <p> 确实很有意思,原题目如下: </p> <blockquote> <p> <code class="js plain" style="line-height: 24px; white-space: pre-wrap; color: rgb(0, 0, 0); border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border-bottom-right-radius: 0px !important; border-bottom-left-radius: 0px !important; background-image: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; margin: 0px !important; outline: rgb(0, 0, 0) !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: 'Courier New', Consolas, 'Bitstream Vera Sans Mono', Courier, monospace !important; min-height: auto !important;">window.alert = </code><code class="js keyword" style="line-height: 24px; white-space: pre-wrap; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border-bottom-right-radius: 0px !important; border-bottom-left-radius: 0px !important; background-image: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; margin: 0px !important; outline: rgb(0, 0, 0) !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: 'Courier New', Consolas, 'Bitstream Vera Sans Mono', Courier, monospace !important; min-height: auto !important; color: rgb(0, 0, 255) !important;">function</code><code class="js plain" style="line-height: 24px; white-space: pre-wrap; color: rgb(0, 0, 0); border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border-bottom-right-radius: 0px !important; border-bottom-left-radius: 0px !important; background-image: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; margin: 0px !important; outline: rgb(0, 0, 0) !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: 'Courier New', Consolas, 'Bitstream Vera Sans Mono', Courier, monospace !important; min-height: auto !important;">(){};______;alert(1); 填空,使后面的alert(1)能正确弹出,至少列举两种不同思路。</code> </p> </blockquote> <p> <code class="js plain" style="line-height: 24px; white-space: pre-wrap; color: rgb(0, 0, 0); border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border-bottom-right-radius: 0px !important; border-bottom-left-radius: 0px !important; background-image: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; margin: 0px !important; outline: rgb(0, 0, 0) !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: 'Courier New', Consolas, 'Bitstream Vera Sans Mono', Courier, monospace !important; min-height: auto !important;">一开始我只想到了delete掉这个重写的方法,以及从原window的原型链中找回原来的alert方法(结果这两种兼容性都不好),不过作者给出了几个很不错的办法,很有意思。...</code></p>

1 / 1