Flash fscommand not working Internet Explorer 9 - javascript

I'm working on an e-learning project where I need to provide interaction between Flash and Moodle's SCORM Javascript API.
Actually this is done already. It was made with fscommand but when it comes to Internet Explorer 9 it stops working.
This is an old legacy project and there is a lot relying on these interactions so I can't simply change it to ExternalInterface (which I have been using in recent projects).
I've tried changing allowScriptAccess to "always" but it didn't work. I've also tried using meta http-equiv="X-UA-Compatible" with several different content values but it didn't work too.
Using any other technology also isn't an option.
If does someone have any suggestions or a solution that worked for any similar case, I would like to know.
Thanks in advance.

Digging up some old knowledge I remember you can emulate IE8. Sound like you may have tried that.
meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8"
Maybe try IE7.

Thanks for the reply, Mark. Yes, you guessed it right. I had tried EmulateIE8 and lesser, but no success.
After a lot of research, I came to a solution, but I couldn't do it without giving up on fscommand.
Before:
I had an embeded SWF calling fscommand and a Javascript API with a _DoFsCommand function that handled the SCORM API Interactions. The SCORM response were passsed back to the SWF by Javascript's native SetVariable function.
Then:
I changed all my fscommand calls to ExternalInterface.call calling directly the _DoFsCommand function and passing to it its expected values. So, even giving up on Flash's fscommand I could keep the rest of the code.
Then I came to another problem, the SetVariable function varies depending on the DOM Object and the Internet Explorer version. It can be embed's function or object's function. So I had to check if the embed did have the SetVariable function before calling it. If it didnt I call it from the object.
This way I guarantee that all versions of Internet Explorer would support Flash's request and SCORM responses without major changes in my project.

Related

Error with Javascript in Internet Explorer

I am new to coding and in my first year of university studying Web Technologies. For my web assignment I had to create a web application which would allow the user to set different preferences for careers and display the careers which match the preferences.
Anyway I have managed to do this but I have a problem in Internet Explorer, my site works fine in Safari, Chrome and Firefox. However, in IE when you press my search button no JavaScript seems to run. I have debugged my site in IE and it has come up with an error for this section of code:
var resetBtn = document.getElementById("resetBtn");
resetBtn.addEventListener("click", reset, false);
The error occurs on the second line and the message is:
Object doesn't support property or method
What do I have to do to fix the error?
Link to screenshot
Thank You
In Internet Explorer you need to use attachEvent
Related Question: MSIE and addEventListener Problem in Javascript?
Yeah, like said before, IE doesn't know addEventListener method, so, you need to do this:
var resetBtn = document.getElementById("resetBtn");
if( resetBtn.addEventListener ){
resetBtn.addEventListener("click", reset, false);
}else{
resetBtn.attachEvent("onclick", reset);
}
This way, you're doing the correct way which is to check for abilities of the browser. In this case in particular, we are testing if the browser supports addEventListener (standard method) if not, fallback to IE method which is attachEvent and the event name must be preceded by an "on" word.
Again, as mentioned above, you can include a library such as jquery, prototype, mootools, etc. But i would strongly suggest to keep it in pure JS for learning purposes, yeah, libraries help you code more quickly, but you'll skip a lot of learning and besides, pure JS is WAY faster than any library any day, any time.
Hope this helps.
It seems your IE is in compatibility mode, behaving as old versions that did not support addEventListener. If you don't care about IE 8 and earlier, you can force the browser out of compatibility mode by issuing a X-UA-Compatible header from your server. You can also set the following meta tag on the <head> of your HTML file (although issuing a proper HTTP header from the server is also highly recommended):
<meta http-equiv="X-UA-Compatible" content="IE=Edge" >
If you need to support old IE, look into attachEvent as suggested in aug's answer.

How to package JavaScript as a .NET Internet Explorer 9 Plugin?

How to .NET package JavaScript as an Interner Explorer 8/9 Plugin, with the JS to be included in all IE browser pages?
I have recently finished writing JavaScript code for a browser addon, which basically runs on page-load via a JS load event listener, and for given domains it then checks for certain elements in the DOM and adds new relevant elements(i.e. information) to the page.
Since the JavaScript only reads/affects the HTML DOM independently (and does not need any toolbar buttons or anything else) the JS purely needs adding to the browser's webpages.
I have packaged the code to work with Firefox and Chrome and those are both working well, and I can run the code for IE in 'bookmarklet' form without problems, but I would like to learn how to package JavaScript as an actual .NET .MSI addon/plugin that will install for the current Internet Explorer 8/9.
Does anyone know of a suitable guide or method I might refer to please? I have tried searching online for tutorials but most walkthroughs refer to writing the plugin body itself (usually in other languages) and are thus not regarding packing existing JS.
I hope someone might have the solution please?
Note: Someone packaged an old version for me as a MSI installer for Internet Explorer 7 a year ago, which installed into Program Files with a plugin.dll plugin.tlb and plugin.InstallState plus BandObjectLib.dll Interop.SHDocVw.dll and Microsoft.mshtml.dll if that is useful.
Edit: Does anyone else know of any other options please?
IE doesn't have a mechanism for this, there simply is no JavaScript based extension ecosystem (though there are other methods to create extensions) for those browsers, yet. IE8 won't be getting one, you can pretty much guarantee that, IE9...we'll see what happens.
The closest JavaScript option available to you would be bookmarklets, which have much more limited functionality...but it's what's available.
Check out http://www.add-in-express.com/programming-internet-explorer/ and http://www.add-in-express.com/programming-internet-explorer/deployment.php they sell a package for this. It will cost you 200 dollar, but will save you allot of time (atleast, It saved me allot of time :) ).
I found a tutorial to create a plugin that loads JS-Code
http://shout.setfive.com/2012/05/01/internet-explorer-extension-quick-start-and-skeleton/

Accessing Flash functions through jQuery

I use the following jQuery code to access functions in my SWF (FP 10.1 SWF embedded via SWFObject):
$('#FlashApp')[0].someFunc();
This works fine in every browser.. except for Internet Explorer (surprise!). Surely, the point of jQuery is to make this code work across all browsers? I'd really rather not write extra code to check for IE.
How can I talk to my SWF in a browser independent way?
Dousn't sound like a jQuery problem. Try the following in IE to see if you get the same results:
document.getElementById('FlashApp').someFunc();
It turns out that the issue was due to IE not being able to talk to an invisible SWF.
you need External Interface
http://blog.flexexamples.com/category/externalinterface/

Browser compatibility; Before or after uploading website to server?

I am on the stage where I need to make my website cross-browser compatible.
I need tips on how to get started.
I have developed my website on firefox, so it works great with firefox.
I guess I have to download a couple of versions of all major browsers now, right?
Then just test each browser one by one?
Should I do this before uploading the entire website onto a server or afterwards?
All tips and SW which makes this easier is appreciated.
BTW, it is a classifieds website using MySql, Solr, PHP, js etc...
Thanks
Cross-browser compatibility is best planned for in advance, as there are ways to build your site that will make it much easier.
Consider using a CSS reset script like Eric Meyer's.
Consider using a JavaScript library like jQuery.
You can make use of Adobe BrowserLab to do cross-browser testing.
Consider the mobile audience.
You need to have some kind of local webserver so you can edit the code and test it in a comfortable way. It is also helpful if you make it accessible for validator.w3.org so you can do syntax checking.
Testing it in IE6, 7 and 8, Firefox and Chrome would be a good start I would say.
Since you are working with server side code, you need to have a server.
Once the site goes live you will need both a live and a development server.
Yes, I'd make it cross browser compatible before uploading to the server. The reason for this is that you may need to change the server-side code, adding ids and classes to the markup, plus it may well be necessary to change the markup. Make sure it's working locally first.
IE Tester is very useful for testing on the various IE browsers. I'd ensure that I've tested it on a Webkit browser (such as Chrome), a Gecko Browser (such as Firefox) and Opera. See this list for different browsers.

flash interaction with javascript internet explorer

I have a flash object interacting with a javascript function. The interaction works fine in every browser except in IE (all versions)
I have tried with swfobject and with classic embeding. AllowScriptAccess is set to "always". Is there any cause for this flaw ?
Thanks
If you're using ExternalInterface, the problem may be related to the way you're attempting to reference the object in JavaScript. Take a look at my answer to this question -- it might not be exactly the same issue, but my answer provides an end-to-end example of ExternalInterface that's been tested on IE, too, so you might want to compare it to your own to see whether anything's missing or out of place.
If that doesn't help, though, try posting some code, so we can have a look at what's going on and maybe diagnose the problem more specifically.
If you are running the test from a file instead of testing it on a webserver it might be because security settings.

Categories