在当前页面使用 `<a target="_blank">` 或 `window.open()` 打开新页面时,如果不做特殊处理,在新页面中可以使用 `window.opener` 访问当前页面的 `window` 对象。
后果是在新页面中能够重置当前页面的 url 地址:`window.opener.location = 'evil.com'`
为了避免这类事情发生,我们可以使用下图的做法。
参考链接:
mathiasbynens.github.io
后果是在新页面中能够重置当前页面的 url 地址:`window.opener.location = 'evil.com'`
为了避免这类事情发生,我们可以使用下图的做法。
参考链接:
展开
2
24