老孟!来拿分!给你的! 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;} myeclipse下extjs怎么实现智能提示,extjs代码如何调试 json格式数据如何显示在fusionchart中 点击按钮运行打开新窗口运行文本框中JS的问题 extjs tree图标 求一个js写的滚图源代码 我弹出的对话框为会不能保存? 请问如何制作图片动态菜单??? asp.net 如何调用self host的 wcf service 有谁对Dreamweaver很熟呀? 请问如何用javascript读出文件的大小。 请问这行代码错在哪里?高分相送!!! 各位高手:请指点做这样的一个菜单是怎么做的?
<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;
}