View Full Version : Call to JavaScript fails in IE but works in FF!
msmedley
03-12-2008, 01:48 PM
I've spent a lot of time trying to figure this out. I've used fscommand, ExternalInterface, and the JavaScript Flash Gateway. I've used Flash MX 2004 and Flash CS3 Pro (Flash 8). The result is the same - it works in Firefox, but doesn't in IE. It doesn't matter if it's IE6 or IE7. I've tried it from different computers. Same result. I'm going nuts!
I've created a stripped out version of my app to demonstrate the problem. The app does nothing but run onload, which uses fscommand to call my JavaScript function.
The HTML file that shows the problem. In IE, it fails. In Firefox, it says "hello, world!"
http://www.mikesmedley.com/test/test.html
The FLA file that contains the stripped down app. Look in onload for the call to fscommand.
http://www.mikesmedley.com/test/test.fla
After publishing the test.swf and test.html files, edit the test.html file to include this JavaScript file which has the DoFSCommand in it.
http://www.mikesmedley.com/test/jsalert.js
Someone must have run into this problem. Please help!
ninjapeps
03-13-2008, 03:01 AM
I'm having the same problem. I copied everything in the ExternalInterface.addCallback portion of the Help section but it refuses to work in IE. here's the entirety of my code:
//the actionscript portion
import flash.external.*;
var methodName:String = "goHome";
var instance:Object = null;
var method:Function = goToMacromedia;
var wasSuccessful:Boolean = ExternalInterface.addCallback(methodName, instance, method);
var txtField:TextField = this.createTextField("txtField", this.getNextHighestDepth(), 0, 0, 200, 50);
txtField.border = true;
txtField.text = wasSuccessful.toString();
function goToMacromedia() {
txtField.text = "http://www.macromedia.com";
getURL("http://www.macromedia.com", "_self");
}
<!-- the html portion -->
<form>
<input type="button" onclick="callExternalInterface()" value="Call ExternalInterface" />
</form>
<script>
function callExternalInterface() {
thisMovie("test").goHome();
}
function thisMovie(movieName) {
if (navigator.appName.indexOf("Microsoft") != -1) {
return window[movieName]
}
else {
return document[movieName]
}
}
</script>
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8 444553540000"
codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="320"
height="240" id="test">
<param name="allowScriptAccess" value="sameDomain" />
<param name="movie" value="test.swf" />
<embed src="test.swf" width="320" height="240" name="test" allowScriptAccess="sameDomain"
type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object>
Arodicus
03-14-2008, 12:00 AM
I've noticed situations where FF is able to handle ExternalInterface calls, while IE cannot, and it usually boils down to the name and id parameters not matching. They must match exactly, or callbacks will fail.
Also check the tags to make sure they even HAVE name/id specified, for that matter.
Try using AC_Runcontent.js from Adobe, rather than formatting your own object/embeds. I was always getting the two confused, and found that using the canned script tended to make things easier since it also turns on the proper security settings.
TeckniX
04-11-2008, 07:31 PM
I'm having a similar problem, except it works in IE but not in Firefox...
Anyway - msmedley, the reason your code isn't working, is because you're missing one of the key elements for the fscommand to work in IE
Add the following to the bottom of the page:
<!--[if IE]>
<script type="text/javascript" event="FSCommand(command,args)" for="test">
test_DoFSCommand(command,args);
</script>
<![endif]-->
seventhapex
07-14-2008, 03:41 PM
IE rejects scriptAccess due to security settings. Set your IE security settings to low and your script should work (if you're having the same issue I am). Does anyone know how to get the Flash scriptAccess to pass normal security levels in IE?
|
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.