tags:

views:

19

answers:

1

Hi,

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.

A: 

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.

Tony Andrews
Understand that it works fine in IE6 but just to let you know that instead of using frames, I actually changes the code to reference an iframe src using document.getElementById("iframe").src = dashboard.urlI think the issue is with the setTimeout call in Apex. As a test Tony, create a dummy function in the above code that alerts a message and call that function using the setTimeout("yourFunction();",5000) and hopefully you'll see that it won't work.Pls let us know - thanks.
tonsils
Furthermore, I am using my intranet URLs and not referencing google.com or stackoverflow urls in my code.
tonsils
OK, I don't have Apex 3.0 but tested it with Apex 4.0 at apex.oracle.com and it works fine: http://apex.oracle.com/pls/otn/f?p=37742:1
Tony Andrews
Sorry, I should say it worked fine once I added an ID of "displayArea" to the frame.
Tony Andrews
thanks for that Tony - not sure why it's not working for me.
tonsils