老孟!来拿分!给你的! child.html必须是window.open()打开的才行 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <html><head><title>PARENT AND CHILD WINDOWS</title><script language='JavaScript'>var newwin=new newwin();function newwin(alertmess){ this.alertmess=alertmess;}function alertmess(){ window.alert('success!');}</script></head><body BGCOLOR="#c0c0c0"><a href="javascript:void(window.open('child.html'))">Create a child window</a><br><input type='submit' onclick=alertmess()></body></html>===============<html><head><script language='javascript'>function getParent(){window.opener.alertmess();}</script><title>PARENT AND CHILD WINDOWS</title></head><body><input type='submit' value='get parent message' onclick=getParent()></body></html> 也可以这样:<html><head><title>PARENT AND CHILD WINDOWS</title><script language='JavaScript'>var newwin=new newwin();function newwin(){ this.alertmess=alertmess;}function alertmess(){ window.alert('success!');}</script></head><body BGCOLOR="#c0c0c0"><a href="javascript:void(window.open('child.html'))">Create a child window</a><br><input type='submit' onclick=alertmess()></body></html>=======<html><head><script language='javascript'>function getParent(){window.opener.newwin.alertmess();}</script><title>PARENT AND CHILD WINDOWS</title></head><body><input type='submit' value='get parent message' onclick=getParent()></body></html> 还是不行啊!如果把子窗口里中window.opener.newwin.alertmess();里的newwin删掉就可以,window.opener.alertmess();这是为什么?我自己定义的对象中的方法定义有问题吗?麻烦给看看! 当前的源文件:parent.html////////////<html><head><title>PARENT AND CHILD WINDOWS</title><script language='JavaScript'>function alertmess(){ window.alert('success!');}function newwin(){ This.alertmess=alertmess();}newwin=new newwin();</script></head><body BGCOLOR="#c0c0c0"><a href="javascript:void(window.open('child.html'))">Create a child window</a><br><input type='submit' onClick=alertmess()></body></html>child.html//////////////<html><head><script language='javascript'>function getParent(){ if(window.opener.newwin==null){ alert("newwin is null!"); } window.opener.alertmess();}</script><title>PARENT AND CHILD WINDOWS</title></head><body><form name='newwindow'><input type='submit' value='get parent message' onClick=getParent()></form></body></html> 你是说我的parent.html里的自定义对象有问题?如果是应该怎么改啊?!我很着急! function newwin(){ this.alertmess=alertmess;} 请问浏览器禁用JS,浏览到的页面源文件里还有脚本 定制网站中上传图片然后调整图片大小功能是如何做的呢? 仿51job后台简历信息添加功能 avaScript W3C下出错 javascript解析xml 遍历查询 怎样删除GridView第一条记录 ===倾家荡产请高手指点:多框架页面如何在进入打印预览页面的时候直接选中“仅打印选定框架”?===在线等,解决后立刻结贴! //如何使一个页面始终在最前面?我这样写怎么不对啊? 简单问题,请进 请教JQUERY如何实现这样效果 请问这行代码错在哪里?高分相送!!! 各位高手:请指点做这样的一个菜单是怎么做的?
<head>
<title>PARENT AND CHILD WINDOWS</title>
<script language='JavaScript'>
var newwin=new newwin();
function newwin(alertmess){
this.alertmess=alertmess;
}
function alertmess(){
window.alert('success!');
}
</script></head>
<body BGCOLOR="#c0c0c0">
<a href="javascript:void(window.open('child.html'))">Create a child window</a><br>
<input type='submit' onclick=alertmess()>
</body>
</html>===============<html>
<head>
<script language='javascript'>
function getParent(){
window.opener.alertmess();
}
</script>
<title>PARENT AND CHILD WINDOWS</title>
</head>
<body>
<input type='submit' value='get parent message' onclick=getParent()>
</body>
</html>
<html>
<head>
<title>PARENT AND CHILD WINDOWS</title>
<script language='JavaScript'>
var newwin=new newwin();
function newwin(){
this.alertmess=alertmess;
}
function alertmess(){
window.alert('success!');
}</script></head>
<body BGCOLOR="#c0c0c0">
<a href="javascript:void(window.open('child.html'))">Create a child window</a><br>
<input type='submit' onclick=alertmess()>
</body>
</html>
=======
<html>
<head>
<script language='javascript'>
function getParent(){
window.opener.newwin.alertmess();
}
</script>
<title>PARENT AND CHILD WINDOWS</title>
</head>
<body><input type='submit' value='get parent message' onclick=getParent()></body>
</html>
如果把子窗口里中window.opener.newwin.alertmess();里的newwin删掉就可以,
window.opener.alertmess();
这是为什么?
我自己定义的对象中的方法定义有问题吗?
麻烦给看看!
parent.html
////////////
<html>
<head>
<title>PARENT AND CHILD WINDOWS</title>
<script language='JavaScript'>
function alertmess(){
window.alert('success!');
}
function newwin(){
This.alertmess=alertmess();
}newwin=new newwin();
</script></head>
<body BGCOLOR="#c0c0c0"><a href="javascript:void(window.open('child.html'))">Create a child window</a><br>
<input type='submit' onClick=alertmess()>
</body>
</html>child.html
//////////////<html>
<head>
<script language='javascript'>function getParent(){
if(window.opener.newwin==null){
alert("newwin is null!");
}
window.opener.alertmess();
}
</script>
<title>PARENT AND CHILD WINDOWS</title>
</head>
<body>
<form name='newwindow'>
<input type='submit' value='get parent message' onClick=getParent()>
</form>
</body>
</html>
如果是应该怎么改啊?!
我很着急!
this.alertmess=alertmess;
}