87,910
社区成员
发帖
与我相关
我的任务
分享
<head>
<script>
var NewWin;
function OpenNewWin(){
NewWin=window.open('http://baidu.com','Newwin','toolbar=no,status=no,width=50,height=50');
}
function CloseNewWin(){
try{
NewWin.close=MyClose; //为什么这句话会报错呢???为什么下面的 NewWin.close()可以调用但是 不能更改NewWin.close呢??
}catch(e){
alert(e.message); //这里显示错误信息:对象不支持此操作
}
NewWin.close();
}
function MyClose(){
alert('myclose');
}
</script>
</head>
<body>
<input type= "button" value = "打开一个新窗口" onClick = "OpenNewWin();">
Click this first
<p>
<input type = "button" value = "关闭新打开的窗口" onclick = "CloseNewWin();">
Then click this
</body>
<html>
<head>
<script>
var NewWin;
function OpenNewWin(){
NewWin=window.open('','Newwin','toolbar=no,status=no,width=50,height=50');
var d = NewWin.window.document;
d.write('<html><head><title>无标题文档</title><style type="text/css">\
html, body{margin:0; padding:0;}</style>\
</head><body><iframe id="frm" width="100%" height="100%" frameborder="0"></iframe></body></html>');
d.close();
var frame = d.getElementById("frm");
frame.src = "http://www.baidu.com/";
}
function CloseNewWin(){
try{
NewWin.window.close = MyClose; //为什么这句话会报错呢???为什么下面的 NewWin.close()可以调用但是 不能更改NewWin.close呢??
}catch(e){
alert(e.message); //这里显示错误信息:对象不支持此操作
}
NewWin.close();
}
function MyClose(){
alert('myclose');
}
</script>
</head>
<body>
<input type= "button" value = "打开一个新窗口" onClick = "OpenNewWin();">
Click this first
<p>
<input type = "button" value = "关闭新打开的窗口" onclick = "CloseNewWin();">
Then click this
</p>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head>
<script type="text/javascript">
var NewWin;
function OpenNewWin(){
NewWin=window.open('http://baidu.com','Newwin','toolbar=no,status=no,width=50,height=50');
}
function CloseNewWin(){
try{
//NewWin.close=MyClose; //为什么这句话会报错呢???为什么下面的 NewWin.close()可以调用但是 不能更改NewWin.close呢??
NewWin.close(MyClose())/*这样可能达到你要的效果~~~,不信瞧瞧~~~*/
}catch(e){
/*可能window.close是一个内部方法,它的作用就是关闭窗口,可能不许客户端重新定义吧*/
alert(e.message); //这里显示错误信息:对象不支持此操作
}
//NewWin.close();
}
function MyClose(){
alert('myclose');
}
</script>
</head>
<body>
<input type= "button" value = "打开一个新窗口" onClick = "OpenNewWin();">
Click this first
<p>
<input type = "button" value = "关闭新打开的窗口" onclick = "CloseNewWin();">
Then click this
</body>
<html>
<head>
<script>
var NewWin;
function OpenNewWin(){
NewWin=window.open('B.html?url=http://www.baidu.com','Newwin','toolbar=no,status=no,width=50,height=50');
}
function CloseNewWin(){
try{
NewWin.window.close = MyClose; //为什么这句话会报错呢???为什么下面的 NewWin.close()可以调用但是 不能更改NewWin.close呢??
}catch(e){
alert(e.message); //这里显示错误信息:对象不支持此操作
}
NewWin.close();
}
function MyClose(){
alert('myclose');
}
</script>
</head>
<body>
<input type= "button" value = "打开一个新窗口" onClick = "OpenNewWin();">
Click this first
<p>
<input type = "button" value = "关闭新打开的窗口" onclick = "CloseNewWin();">
Then click this
</p>
</body>
</html>
<html>
<head>
<title>无标题文档</title>
<style type="text/css">
html, body{
margin:0; padding:0;
}
</style>
<script type="text/javascript">
window.onload = function(){
var url = window.location.search.split("=")[1];
var frm = document.getElementById("frm");
frm.src = url;
}
</script>
</head>
<body>
<iframe id="frm" width="100%" height="100%" frameborder="0"></iframe>
</body>
</html>
<head>
<script>
var NewWin;
function OpenNewWin(){
NewWin=window.open('http://baidu.com','Newwin','toolbar=no,status=no,width=50,height=50');
}
function CloseNewWin(){
try{
NewWin.window.close=MyClose; //改成NewWin.window了,但是下面显示没有权限.
}catch(e){
alert(e.message); //这里显示“没有权限”
}
NewWin.close();
}
function MyClose(){
alert('myclose');
}
</script>
</head>
<body>
<input type= "button" value = "打开一个新出窗口"
onClick = "OpenNewWin();">
Click this first
<p>
<input type = "button" value = "关闭新打开的窗口"
onclick = "CloseNewWin();"> Then click this
</body>
NewWin.close(MyClose())
/*先执行MyClose(),再执行NewWin.close*/
可以用iframe链接到跨域页面,然后控制iframe的父页面即可open的页面
function OpenNewWin(){
NewWin=window.open('http://baidu.com','Newwin','toolbar=no,status=no,width=50,height=50');
}
function CloseNewWin(){
NewWin.close();
}