JavaScript 调用“setTimeout”在 Oracle Apex 中不起作用

发布于 2024-09-07 07:29:37 字数 1134 浏览 3 评论 0原文

我正在尝试从 Oracle ApeX 中的 Stack Overflow 中的该线程运行此代码,看起来 setTimeout 调用未按预期工作:

[see thread][1]

<html lang="en">
<head>
<title>Dashboard Example</title>
<style type="text/css">
body, html { margin: 0; padding: 0; width: 100%; height: 100%; overflow: hidden; }
iframe { border: none; }
</style>
<script type="text/javascript">
var Dash = {
    nextIndex: 0,

    dashboards: [
        {url: "http://www.google.com", time: 5},
        {url: "http://www.yahoo.com", time: 10},
        {url: "http://www.stackoverflow.com", time: 15}
    ],

    display: function()
    {
        var dashboard = Dash.dashboards[Dash.nextIndex];
        frames["displayArea"].location.href = dashboard.url;
        Dash.nextIndex = (Dash.nextIndex + 1) % Dash.dashboards.length;
        setTimeout(Dash.display, dashboard.time * 1000);
    }
};

window.onload = Dash.display;
</script>
</head>
<body>
<iframe name="displayArea" width="100%" height="100%"></iframe>
</body>
</html>

How can I get this call to work in Oracle ApEx v3.0.1?

I am trying to run this code from this thread in Stack Overflow in Oracle ApeX and it looks as if the setTimeout call is not working as suppose to:

[see thread][1]

<html lang="en">
<head>
<title>Dashboard Example</title>
<style type="text/css">
body, html { margin: 0; padding: 0; width: 100%; height: 100%; overflow: hidden; }
iframe { border: none; }
</style>
<script type="text/javascript">
var Dash = {
    nextIndex: 0,

    dashboards: [
        {url: "http://www.google.com", time: 5},
        {url: "http://www.yahoo.com", time: 10},
        {url: "http://www.stackoverflow.com", time: 15}
    ],

    display: function()
    {
        var dashboard = Dash.dashboards[Dash.nextIndex];
        frames["displayArea"].location.href = dashboard.url;
        Dash.nextIndex = (Dash.nextIndex + 1) % Dash.dashboards.length;
        setTimeout(Dash.display, dashboard.time * 1000);
    }
};

window.onload = Dash.display;
</script>
</head>
<body>
<iframe name="displayArea" width="100%" height="100%"></iframe>
</body>
</html>

How can I get this call to work in Oracle ApEx v3.0.1?

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

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

发布评论

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

评论(1

标点 2024-09-14 07:29:37

这个问题与 Apex 无关 - 事实上,您可以获取您发布的 HTML,将其保存到文件中,然后在浏览器中运行该文件来测试它。

不幸的是,www.google.com 是一个无法使用此代码的 URL,因为它包含一些自己的“framebusting”Javascript,会将其从框架中弹出到浏览器窗口中,之后您的代码将不再运行。 stackoverflow.com 也做了类似的事情。
例如,如果您将第一个 URL 更改为 www.bbc.com,那么它会起作用(无论如何在 IE 上),直到它到达 stakoverflow.com,此时它会弹出框架。

This problem is nothing to do with Apex - in fact you can take the HTML you posted, save it to a file, and run that file in a browser to test it.

Unfortunately, www.google.com is a URL that will not work with this code, because it contains some "framebusting" Javascript of its own that pops it out of the frame into the browser window, after which your code is no longer running. stackoverflow.com does something similar.
If you change the first URL to www.bbc.com for example then it works (on IE anyway) until it gets to stakoverflow.com, when it pops out of the frame.

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