JavaScript调用`setTimeout`在Oracle Apex中不起作用 [英] JavaScript call `setTimeout` not working in Oracle Apex

查看:118
本文介绍了JavaScript调用`setTimeout`在Oracle Apex中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从Oracle ApeX的Stack Overflow中的此线程运行此代码,并且好像setTimeout调用无法正常工作:

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>

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

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

推荐答案

此问题与Apex无关-实际上,您可以获取发布的HTML,将其保存到文件中,然后在浏览器中运行该文件以进行测试.

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.

不幸的是,www.google.com是一个不适用于此代码的URL,因为它包含一些自己的"framebusting" Javascript,将其从框架中弹出到浏览器窗口中,此后您的代码就没有了.运行时间更长. stackoverflow.com做类似的事情. 例如,如果将第一个URL更改为www.bbc.com,则该URL仍将起作用(无论如何在IE上),直到它弹出框架时到达stakoverflow.com.

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.

这篇关于JavaScript调用`setTimeout`在Oracle Apex中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆