IFrame event executes fine in HTML but not in HTA

牧云@^-^@ 提交于 2020-01-02 16:19:26

问题


This HTML file shows message dialog when button inside iframe is clicked:

<!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>

While same document as HTA file, raises error: 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>

Why is that, or how can I execute parent function with onclick event from iframe button in HTA?


回答1:


Use:

<iframe id="frame" onload="load_me" application="yes"></iframe>

See Intro to .HTA, section The Power of Trust: HTAs and Security



来源:https://stackoverflow.com/questions/14834888/iframe-event-executes-fine-in-html-but-not-in-hta

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!