PDA

View Full Version : OL4 DHTML IE7 not finding <script> function


guyr
06-01-2007, 01:03 AM
I'm using OL4 to target the DHTML runtime. From a JSP page, I open a new window to run the OL4 application. When a button is clicked in the OL4 application, I need to change the displayed page back in the original window. By trial and error, I found the way to do this is top.opener.location.ref="new-url".

Here is my handler function for the button:

<handler name="onclick">
// Debug.write("href: " + this.href);
// changeSccWindow(href);
// LzBrowser.loadJS("top.opener.location.href='" + href + "';");
// LzBrowser.loadJS("top.opener.location.href='" + href + "';top.opener.focus();");
// top.opener.location.href="/scc/html/index.jsp";
// top.opener.focus();
</handler>

And here is the <script> block on the canvas:

<script>
<![CDATA[
function changeSccWindow(href)
{
// Debug.write("href: " + href);
// alert(href);
// LzBrowser.loadJS("window.opener.location.href=" + href);
// top.opener.location.href="/scc/html/index.jsp";
// top.opener.focus();
}
]]>
</script>

I did a lot of trial and error, which is why so much is commented out. Briefly, I discovered that LzBrowser.loadJS() works fine for Firefox for both DHTML and Flash 8 runtimes; for IE7, it only works for Flash 8.

If I uncomment the call to changeSccWindow() and the alert and top.opener calls inside that function, DHTML works for for Firefox. For IE7, nothing happens, so I'm guessing that the function is not getting called. No errors are being generated.

Now if I comment everything back out, and uncomment the two top.opener statements in the handler, both Firefox and IE7 work. This seems to confirm that the <script> function is not getting invoked under IE7. Any ideas?

Any alternative way to accomplish the task that will work under both runtimes and both browsers? Thanks. For anyone interested, top.opener.focus() does not work under either browser if you are using tabs. I spent a couple hours searching the net, and apparently this is by design.

ptw
06-01-2007, 11:44 AM
Can you show exactly the cases that work and don't work? I can't make out from your prose what the working and non-working cases are. If you want to work across runtimes, you need to use loadJS (because the browser DOM is not accessible from SWF). I would use `Debug.write` as your test for whether something is called or not, as `alert` is also not available across runtimes.

It is possible you are running afoul of a security constraint, that IE will not _let_ you change the url of another window. Perhaps try changing the security level of your browser to test that theory.

guyr
06-03-2007, 08:01 PM
Ok, here is a complete example. Our primary target runtime is dhtml. Notice that with dhtml, IE7 doesn't do anything and generates no errors. Appreciate your looking into this.

<canvas>
<script>
<![CDATA[
function clickMe()
{
Debug.write("I'm clicked");
// Firefox swf8 shows
// Firefox dhtml shows
// IE7 swf8 shows
// IE7 dhtml doesn't show, no error

alert("I'm clicked");
// Firefox swf8 undefined function alert
// Firefox dhtml shows
// IE7 swf8 undefined function alert
// IE7 dhtml doesn't show, no error
}
]]>
</script>

<view>
<button text="Click me" onclick="clickMe()"></button>
</view>
</canvas>

guyr
06-11-2007, 10:21 AM
Has anyone had any success invoking Javascript functions within <script> tags on the canvas using IE? I was able to work around the original issue I had when I created this topic, but now I genuinely need a Javascript function on the canvas that I cannot work around. Appreciate hearing from anyone who has gotten this to work. Thanks.