為什么我把關(guān)閉放在按鈕函數(shù)里面實(shí)現(xiàn)不了關(guān)閉網(wǎng)頁(yè)
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>close()</title>
? <script type="text/javascript">
? ? ?var mywin=window.open("http://idcbgp.cn");
?function myclose()
?{
? ? ?mywin.close();
?}
? </script>
</head>
<body>
? ? <input name="button" type="button" onClick="myclose()" value="close">
</body>
</html>
2019-07-18
這個(gè)是因?yàn)槟闶褂玫氖蔷W(wǎng)頁(yè)內(nèi)嵌的工具關(guān)閉的網(wǎng)頁(yè),你把程序復(fù)制到外面創(chuàng)建一個(gè)html的文件打開就可以了。
2019-07-11
可以試試這樣:
<!doctype html>
?<html>
????<meta charset="utf-8">
????<title>close()</title>
? ? <script>
????????????var str=window.open('http://www.baidu.com','_blank','width=400,height=200,top=100,left=100')
????????????????????????function rec(){
????????????????????????????????????????????var str1=confirm("是否退出該網(wǎng)址");
????????????????????????????????????????????if(str1==true){
????????????????????????????????????????????????????????????str.close();
????????????????????????????????????????????????????????}
????????????????????????????????}
? ? ? </script>
? ? ? <body>
????????????????<p>
??????????????????????<input type="button" name="button" value="click" onclick="rec()">
????????????????</p>
? ? ? </body>
</html>
????????????
2019-07-01
function rec_4(){
??? var str = window.open('https://www.baidu.com/','_blank','window=300,height=200,left=0,top=100')
??? var str_1 = confirm("網(wǎng)址不安全是否退出")
??? if(str_1==true){
??????? str.close()
??? }
??? else{
??????? window.open('https://www.baidu.com/','_blank','window=300,height=200,left=0,top=100')
??? }
}
<input type="button" name="type" value="點(diǎn)擊4" onclick="rec_4()">
你可以試試這樣,
2019-06-22
? ? ?var mywin=window.open("http://idcbgp.cn");
?function myclose()
?{
? ? ?mywin.close();
?}
改為:
?function myclose()
?{
? ? ?var mywin=window.open("http://idcbgp.cn");
? ? mywin.close();
?}