在 Adob​​e AIR Flex 4 中的 HTML 组件内运行 javascript?

发布于 2024-10-26 02:47:53 字数 678 浏览 9 评论 0原文

我在 Flex 4 的 AIR 应用程序中具有以下组件:

<mx:HTML id="viewObject"
         x="10" y="42" width="634" height="313"
         location="http;//localhost:8080/mypage.php" />

现在我想在页面加载时运行 javascript,但 javascript 不在目标页面内。我想运行以下 javascript:

javascript:alert('Hello world.');

我尝试通过在页面加载后再次将 location 属性设置为 javascript 来接近它,如下所示。

<s:Button x="10" y="10" label="Button">
    <s:click>
        <![CDATA[
        viewObject.location = "javascript:alert('hello world');";
        ]]>
    </s:click>
</s:Button>

不幸的是,对我来说,这似乎不起作用。有人能帮我解决这个问题吗?

I have the following component in an AIR application from Flex 4:

<mx:HTML id="viewObject"
         x="10" y="42" width="634" height="313"
         location="http;//localhost:8080/mypage.php" />

Now I want to run a javascript when the page loads but the javascript isn't inside the target page. I want to run the following javascript:

javascript:alert('Hello world.');

I tried approaching it by setting the location property again to the javascript after the page has loaded like below.

<s:Button x="10" y="10" label="Button">
    <s:click>
        <![CDATA[
        viewObject.location = "javascript:alert('hello world');";
        ]]>
    </s:click>
</s:Button>

Unfortunately for me, that doesn't seem to work. Can anybody help me out with this problem?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

清音悠歌 2024-11-02 02:47:54

这是因为位置就像使用地址栏一样。你需要做的是这样的:

htmlComponent.htmlLoader.window.alert('hello world');

我认为这应该可行。

That's because location is like using the address bar. What you need to do is something like this:

htmlComponent.htmlLoader.window.alert('hello world');

I think that should work.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文