我试图让iframe窗口的会话超时在20分钟后自动关闭而不发出警告这可能吗?
答案 0 :(得分:0)
这是您的目标代码
<!DOCTYPE html>
<html>
<head>
<title>test</title>
<script type="text/javascript">
function CreateIframe(){
var iframe=document.createElement('iframe');
iframe.setAttribute("src","http://www.disney.com");
iframe.setAttribute("id","target");
iframe.setAttribute("height","200");
iframe.setAttribute("width","200");
document.body.appendChild(iframe);
setTimeout(function(){
var frame = document.getElementById("target");
if(frame!=undefined && frame !=null){
frame.parentNode.removeChild(frame);
}
else{
console.log('Iframe not created yet');
}},20000);}
</script>
</head>
<body>
<input type="button" value="click me" onclick="CreateIframe()" >
</body>
</html>