先上代码,我不会!
以下a,b是通过<frame>加载,
现在想通过b.html中的按钮,点击后**关闭chrome浏览器当前窗体**,请问我该怎么办?
目前已经尝试了好几种
window.location.href="about:blank";
window.close();
window.opener = "";
等等之类的。
求助社区大神
我的目的只有一个 **{关闭chrome浏览器当前窗体}**
```html
frame.html
<html>
<script>
</script>
<frameset cols="25%,50%">
<frame src="a.html">
<frame src="b.html">
</frameset>
</html>
a.html
<html><head></head><body bgcolor="#8F8FBD">
<h3>Frame A</h3>
</body></html>
b.html
<html><head>
<script>
function test(){
}
</script>
</head><body bgcolor="#EBC79E">
<h3>Frame B</h3>
<input type="button" value="five" onClick="test()"/>
</body></html>
```
不知道这个是否满足你的需求。
<script>
function test() {
window.open("about:blank", "_top").close();
}
</script>
不同浏览器关闭方法不同,代码如下:
if (navigator.userAgent.indexOf('MSIE') > 0) { // close IE
if (navigator.userAgent.indexOf('MSIE 6.0') > 0) {
window.opener = null;
window.close();
} else {
window.open('', '_top');
window.top.close();
}
} else { // close chrome;It is effective when it is only one.
window.opener = null;
window.open('', '_self');
window.close();
}