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/
Related
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.
I have a JavaScript function that loads a flash movie into a webpage div using swfobject.embedSWF().
I want to be able to, alternatively, load a .mov file into the same div, in the event that this is the file found instead of the .swf.
Is there a close equivalent to swfobject.embedSWF for the purposes of embedding a .mov file? If not, what is an efficient route to doing this using JavaScript?
QTObject might do what you need and it's from the same author as SWFObject. It's old though, so I'm not sure if it will work well in modern browsers.
EDIT I searched and found reports of it working fine in IE7, Firefox 2 and Opera 9, so you might just be in luck. Just make sure you test it thoroughly.
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.
I don't want to use jQuery, but I'd like to use Ajax to do file uploading. Is that possible?
If so, where can I find information/tutorial on it?
No, it isn't possible to do this with javascript.
In order to give the 'AJAX' feel, however, you can submit a form to a hidden iframe and output the script results to it, then process from there. Google ajax iframe upload and get started from there.
If you are using jQuery, there is also the Form plugin which will automatically create this iframe for you if your form has any file fields in it. I haven't used it to do this, but I've heard good things.
As pointed out in the comments, you can also use something like the very popular SWFUpload to accomplish the desired effect with Flash.
Incase anyone is finding this question much later: yes this is possible with JavaScript now.
HTML5 defined 2 new APIs that you use together to accomplish this: Drag and Drop API and the File API. You can use jQuery to interact with the APIs effectively letting people drag and drop files for upload.
Here is a tutorial on how to do it.
The code currently works in Chrome 6+ and Firefox 3.6+, Safari 6 and IE 10. If you need Safari 5 support, the code stays almost exactly the same but you use the FormData object instead for the uploaded file list (more information in the post).
Opera supports the File API as of 11, but not the DnD API, the drop operation does not initiate the upload, but they support you getting access to the file with the API. I imagine in 12 they will finish off support for DnD API.
01-20-14 Update: All the major browsers implement all the standard APIs now so this tutorial works in all browsers.
i use swfupload for multiple ajax-like uploads (its javascript/flash based)
Here's a bit of detail about how gmail does it, using an iframe:
http://www.sajithmr.com/upload-files-like-gmail/
Assuming you are using Java, DWR version 3.0 (currently in RC1) has support for binary file upload/download, which makes the problem trivially easy. I have not had a chance to try this out yet but we use DWR extensively with total success; it is a great Ajax toolkit.
http://directwebremoting.org/blog/joe/2008/12/16/dwr_version_3_0_release_candidate_1.html
Strictly speaking there are possibilities to do real AJAX file uploads, but this is only possible in Firefox 3+, Safari 4 and Chrome 2. In all other browsers you must use a workaround like the iframe technique or a Flash based uploader.
Haven't used it personally, but Ajax Uploader is a component I recently came across which says it can do file uploads inside an UpdatePanel (assuming you're using ASP.NET).
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.