Html JavaScript调用`setTimeout`在Oracle Apex中不起作用

Html JavaScript调用`setTimeout`在Oracle Apex中不起作用,html,oracle-apex,Html,Oracle Apex,我正在Oracle ApeX中尝试从堆栈溢出中的此线程运行此代码,看起来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%

我正在Oracle ApeX中尝试从堆栈溢出中的此线程运行此代码,看起来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>
[参见线程][1]
仪表板示例
正文,html{边距:0;填充:0;宽度:100%;高度:100%;溢出:隐藏;}
iframe{border:none;}
变量破折号={
下一个索引:0,
仪表盘:[
{url:“http://www.google.com“,时间:5},
{url:“http://www.yahoo.com“,时间:10},
{url:“http://www.stackoverflow.com“,时间:15}
],
显示:函数()
{
var dashboard=Dash.dashboards[Dash.nextIndex];
框架[“displayArea”].location.href=dashboard.url;
Dash.nextIndex=(Dash.nextIndex+1)%Dash.dashboards.length;
设置超时(Dash.display,dashboard.time*1000);
}
};
window.onload=Dash.display;

如何在Oracle ApEx v3.0.1中使用此调用?

此问题与ApEx无关-事实上,您可以将发布的HTML保存到文件中,然后在浏览器中运行该文件以测试它

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

请理解它在IE6中工作正常,但只是要让您知道,我实际上更改了代码,以使用document.getElementById(“iframe”)引用iframe src,而不是使用框架.src=dashboard.url我认为问题在于Apex中的setTimeout调用。作为一个测试,在上面的代码中创建一个虚拟函数来警告一条消息,并使用setTimeout(“yourFunction();”,5000)调用该函数,希望您看到它不会工作。请让我们知道-谢谢。此外,我正在使用我的内联网URL,在我的代码中没有引用google.com或stackoverflow URL。好的,我没有Apex 3.0,但在Apex.oracle.com用Apex 4.0测试了它,它工作正常:对不起,我应该说,在我向框架添加了“displayArea”ID后,它工作正常。