问题
I am trying to run this code from this thread in StackOverflow 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>
If somebody with Oracle ApEx could please try this in v3.0.1, and get it going, pls let me know how.
Thanks.
回答1:
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.
来源:https://stackoverflow.com/questions/3141460/settimeout-not-working-oracle-apex