请高手指教错误在哪????? 因为你的hw() 和 hwwh()这两个函数不是写在打开的窗口里的,当然无法调用~~ 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 把你的js函数写在一个js.js 文件里:function wh(){var xm;var mm;xm=newWindow.document.form1.text1.value;mm=newWindow.document.form1.text2.value;if(xm==""){alert("请填写用户名")} else if(mm==""){alert("请输入密码")} else if(xm!="a"||mm!="0"){alert("您输入的用户名或密码错误,请重新输入")}}function hwwh(){newWindow.document.form1.text1.value="";newWindow.document.form1.text2.value="";}然后: <html><head><script language="JavaScript"><!--function hw(){var newWindow=window.open('','','width=230,height=148,left=300,top=200,ScrollBar=no,menubar=0,toolbar=0');newWindow.document.write("<html>");newWindow.document.write("<head>");newWindow.document.write("<script language='javascript' src='js.js'>"); // 在这里加两行代码newWindow.document.write("</script>");newWindow.document.write("<title>用户登陆</title>");newWindow.document.write("</head>");newWindow.document.write("<body background='hw 1.gif'>");newWindow.document.write("<br>");newWindow.document.write("<form name='form1'>");newWindow.document.write("                       ");newWindow.document.write("<input type='text' name='text1' size=10>");newWindow.document.write("                             ");newWindow.document.write("<input type='text' name='text2' size=10> ");newWindow.document.write("</form>");newWindow.document.write("     ");newWindow.document.write("<img src='hw 3.gif' onclick='wh()'>");newWindow.document.write("     ");newWindow.document.write("<img src='hw 2.gif' onclick='hwwh()'>");newWindow.document.write("     ");newWindow.document.write("<img src='hw4.gif' onclick='self.close()'>");newWindow.document.write("</body>");newWindow.document.write("</html>");newWindow.document.form1.text1.focus();newWindow.document.close();}//--></script></head><body onload="hw()"></body></html> 子窗口不能执行父窗口的函数将函数写到js中调用或直接使用document.write写入调用 这是修改后的正确代码:——————————————————————<html><head><script language="JavaScript"><!--function hw(){var newWindow=window.open('','','width=530,height=548,left=300,top=200,ScrollBar=no,menubar=0,toolbar=0');newWindow.document.write("<html>");newWindow.document.write("<head>");newWindow.document.write("<title>用户登陆</title>");newWindow.document.write("</head>");newWindow.document.write("<body background='hw 1.gif'>");newWindow.document.write("<br>");newWindow.document.write("<form name='form1'>");newWindow.document.write("                       ");newWindow.document.write("<input type='text' name='text1' size=10>");newWindow.document.write("                             ");newWindow.document.write("<input type='text' name='text2' size=10> ");newWindow.document.write("</form>");newWindow.document.write("     ");newWindow.document.write("<img src='hw3.gif' onclick='wh()'>HW3.GIF");newWindow.document.write("     ");newWindow.document.write("<img src='hw2.gif' onclick='hwwh()'>HW2.GIF");newWindow.document.write("     ");newWindow.document.write("<img src='hw4.gif' onclick='self.close()'>HW4.GIF");newWindow.document.write("<script>");newWindow.document.write("function wh(){var xm;var mm;xm=document.form1.text1.value;mm=document.form1.text2.value;if(xm==''){alert('请填写用户名')} else if(mm==''){alert('请输入密码')}else if(xm!='a'||mm!='0'){alert('您输入的用户名或密码错误,请重新输入')}}function hwwh(){document.form1.text1.value='';document.form1.text2.value='';}");newWindow.document.write("</script>");newWindow.document.write("</body>");newWindow.document.write("</html>");newWindow.document.form1.text1.focus();newWindow.document.close();}//--></script></head><body onload="hw()"></body></html> 怎么用JS控制多个DIV的显示和隐藏问题 火狐下文件上传的时候遇到的问题 html inputfile 点击浏览取消的onchange问题 关于对象生成,原型链上的数据初始化问题 onclick事件设置div的visibility javascript:history.back(-2);为什么没有用? RadioButton取值的问题 jscript中如何实现'\'到'\\'的替换 ExtJS4中使用Ext.ux.comboboxtree出现图片重叠问题,请求帮助! 一道阿里巴巴笔试题,求大神解答 如何使用正则表达式进行替换,急急!! 哪位大哥帮忙一下!
function wh(){
var xm;
var mm;
xm=newWindow.document.form1.text1.value;
mm=newWindow.document.form1.text2.value;
if(xm==""){alert("请填写用户名")}
else if(mm==""){alert("请输入密码")}
else if(xm!="a"||mm!="0"){alert("您输入的用户名或密码错误,请重新输入")}
}function hwwh(){
newWindow.document.form1.text1.value="";
newWindow.document.form1.text2.value="";}然后:
<html>
<head>
<script language="JavaScript">
<!--function hw(){
var newWindow=window.open('','','width=230,height=148,left=300,top=200,ScrollBar=no,menubar=0,toolbar=0');
newWindow.document.write("<html>");
newWindow.document.write("<head>");newWindow.document.write("<script language='javascript' src='js.js'>"); // 在这里加两行代码
newWindow.document.write("</script>");newWindow.document.write("<title>用户登陆</title>");
newWindow.document.write("</head>");
newWindow.document.write("<body background='hw 1.gif'>");
newWindow.document.write("<br>");
newWindow.document.write("<form name='form1'>");
newWindow.document.write("                       ");
newWindow.document.write("<input type='text' name='text1' size=10>");
newWindow.document.write("                             ");
newWindow.document.write("<input type='text' name='text2' size=10> ");
newWindow.document.write("</form>");
newWindow.document.write("     ");newWindow.document.write("<img src='hw 3.gif' onclick='wh()'>");
newWindow.document.write("     ");
newWindow.document.write("<img src='hw 2.gif' onclick='hwwh()'>");
newWindow.document.write("     ");
newWindow.document.write("<img src='hw4.gif' onclick='self.close()'>");
newWindow.document.write("</body>");
newWindow.document.write("</html>");
newWindow.document.form1.text1.focus();
newWindow.document.close();}//-->
</script>
</head>
<body onload="hw()"></body>
</html>
将函数写到js中调用或直接使用document.write写入调用
——————————————————————
<html>
<head>
<script language="JavaScript">
<!--function hw(){
var newWindow=window.open('','','width=530,height=548,left=300,top=200,ScrollBar=no,menubar=0,toolbar=0');
newWindow.document.write("<html>");
newWindow.document.write("<head>");
newWindow.document.write("<title>用户登陆</title>");
newWindow.document.write("</head>");
newWindow.document.write("<body background='hw 1.gif'>");
newWindow.document.write("<br>");
newWindow.document.write("<form name='form1'>");
newWindow.document.write("                       ");
newWindow.document.write("<input type='text' name='text1' size=10>");
newWindow.document.write("                             ");
newWindow.document.write("<input type='text' name='text2' size=10> ");
newWindow.document.write("</form>");
newWindow.document.write("     ");newWindow.document.write("<img src='hw3.gif' onclick='wh()'>HW3.GIF");
newWindow.document.write("     ");
newWindow.document.write("<img src='hw2.gif' onclick='hwwh()'>HW2.GIF");
newWindow.document.write("     ");
newWindow.document.write("<img src='hw4.gif' onclick='self.close()'>HW4.GIF");
newWindow.document.write("<script>");
newWindow.document.write("function wh(){var xm;var mm;xm=document.form1.text1.value;mm=document.form1.text2.value;if(xm==''){alert('请填写用户名')} else if(mm==''){alert('请输入密码')}else if(xm!='a'||mm!='0'){alert('您输入的用户名或密码错误,请重新输入')}}function hwwh(){document.form1.text1.value='';document.form1.text2.value='';}");
newWindow.document.write("</script>");
newWindow.document.write("</body>");
newWindow.document.write("</html>");
newWindow.document.form1.text1.focus();
newWindow.document.close();}//-->
</script>
</head>
<body onload="hw()"></body>
</html>