【问题标题】:how to run function from frame如何从框架运行功能
【发布时间】:2015-03-06 07:23:36
【问题描述】:

我有一个文件(CCPageContainer.swt),其中包含帧数和每个帧调用文件。 (swt - siebel 模板文件)

这是带有特定框架的代码的一部分:

<HTML dir="swe:dir">
<head>
<title><swe:this property="Title"/></title>
<swe:include file="CCStylesChoice.swt"/>
</head>

<swe:switch>
    <swe:frameset htmlAttr="rows='30,30,27,18,42,*,15' border='0' frameborder='No'">
       <swe:frame htmlAttr="marginheight='0' marginwidth='0' noresize scrolling='No'">
             <swe:include file="CCFrameGoToView.swt"/>      
       </swe:frame> 
    </swe:frameset>
</swe:switch>
</HTML>

在已调用的 CCFrameGoToView.swt 文件中,我试图调用警报函数:

 <HTML dir="swe:dir">

    <body>
    <script language="JScript">
    function alert_test()
    {
        try
        {
            alert("test");
        }
        catch (err)
        {
            //document.write("oops.. an error has occurred");
        }
    }

 </script>
    <form name="myForm">
    <table>
      <tr>
        <td>ALERT: <input type="Button" value="alert5" onClick="alert_test();"><br></td>
      </tr>
    </table> 
    </form>
<swe:scripts/>
</body>
</html>

问题是当我按下按钮时警报消息不起作用。

如果我只运行 CCFrameGoToView.swt,则警报按钮正在工作,并且我在按下后会看到消息。 但是当我试图从 CCPageContainer.swt 运行它时,当我按下警报按钮时什么也没发生。

我也尝试过 window.parent、window.top 等

请您帮忙。谢谢。

【问题讨论】:

    标签: javascript html frame frameset siebel


    【解决方案1】:

    尝试将您的自定义函数挂在顶部窗口之外,以便点击处理程序能够找到它的路径:

    top.alert_test = function alert_test()
    {
       // blah blah blah
    }
    

    然后:

    onClick="top.alert_test();"
    

    顺便说一句,将代码直接注入到 Siebel Web 模板文件中感觉很奇怪,所以如果您告诉我们更多关于您想要完成的工作,我们或许可以帮助您考虑一个更好的方法来完成它。

    【讨论】:

      猜你喜欢
      • 2014-07-16
      • 1970-01-01
      • 2017-05-16
      • 2021-06-26
      • 1970-01-01
      • 2013-05-30
      • 1970-01-01
      • 2016-01-19
      • 1970-01-01
      相关资源
      最近更新 更多