单击 iframe 内的按钮时,此 HTML 文件会显示消息对话框:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<script language="VBScript" type="text/vbscript">
Sub load_me()
frame.document.write "<input type='button' onclick='parent.message()'>"
End Sub
Sub message()
MsgBox "Hi"
End Sub
</script>
</head>
<body>
<iframe id="frame" onload="load_me"></iframe>
</body>
</html>
虽然与 HTA 文件相同的文档会引发错误:Error: Object doesn't support this property or method
:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Test</title>
<HTA:APPLICATION
APPLICATIONNAME="Test"
ID="MyHTMLapplication"
VERSION="1.0"/>
<script language="VBScript">
Sub load_me()
frame.document.write "<input type='button' onclick='parent.message()'>"
End Sub
Sub message()
MsgBox "Hi"
End Sub
</script>
</head>
<body bgcolor="white">
<iframe id="frame" onload="load_me"></iframe>
</body>
</html>
为什么会这样,或者我如何执行父函数onclick
HTA 中 iframe 按钮的事件?
Use:
<iframe id="frame" onload="load_me" application="yes"></iframe>
See .HTA 简介 http://msdn.microsoft.com/en-us/library/ms536496%28v=vs.85%29.aspx, 部分信任的力量:HTAs 和安全性
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)