ActiveX Object is not defined - firefox

Firebug is giving me the following error:
ActiveXObject is not defined
[Break on this error] var xmlhttp = new ActiveXObject("MSXML2.XmlHttp");
I've read that ActiveX is a Microsoft framework and its mostly used in IE. All of the internal web pages at the place I work were designed and built specifically for IE 6, but now they want me to research what it would take to move to Firefox and Safari and other major browsers... and ActiveX does not work in Firefox.
So how do I get the ActiveX stuff to work in Firefox and Safari specifically on Mac (for starters)? I know there is a couple of plugins? that have made things easier... like FF ActiveX Host... but is there a programmatic solution to this?
If there is no solution, no plugin, for this problem, is it possible to rewrite the ActiveX pieces in Java?

I’m not a web guy but it seems like your web pages use AJAX.
So your problem is not using AcitveX in other browsers.
Try something like this:
var xmlhttp;
if (window.XMLHttpRequest) {
xmlhttp = new XMLHttpRequest();
} else {
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {
xmlhttp = false;
}
}
}

The Plugin-API nearly every relevant browser besides IE supports is the NPAPI, see e.g. this introduction.
I am not aware of any transparent programmatic soutions for adapting ActiveX, especially since its a Windows only technology.
An alternative might be the FireBreath project, which eases working with the NPAPI as well as giving you an abstraction layer over NPAPI and ActiveX - the idea being that you have to write most central parts only once.
Disclaimer: i am one of the owners of the project and thus probably biased ;)

Related

Detect data URI in links support with Modernizr

Using data URI in links (<a href="data:) is not supported in IE and Microsoft Edge (Data URI link <a href="data: doesn't work in Microsoft Edge).
I'm trying to use Modernizr to detect data URI in links support.
Modernizr.datauri is not quite what I'm looking for, as it does not tell anything about support data URI in links, e.g. for Microsoft Edge it returns object {over32kb: true}
How can I detect using Modernizr if data URI in links is supported in browser?
I had the same need for feature detection but I am not using Modernizr. My use case is that I'm generating a pdf on the client side with the makePDF library and was not able to open the PDFs using data URIs in IE or Edge. Unfortuantely, all the feature detection scripts I could find were testing for support of data URIs for images (which is supported by MS browsers) so I had to write my own. Here's the code (thanks to BoltClock's comment above for the idea):
checkDataURISupport(function (checkResult) {
if (checkResult) {
alert('Files in data URIs are supported.');
} else {
alert('Files in data URIs are NOT supported.');
}
})
function checkDataURISupport(callback) {
try {
var request = new XMLHttpRequest();
request.onload = function reqListener() {
callback(true);
};
request.onerror = function reqListener() {
callback(false);
};
request.open('GET', 'data:application/pdf;base64,cw==');
request.send();
} catch (ex) {
callback(false);
}
}
checkDataURISupport()
I tested in in IE 11, Edge 25, Firefox 46, and Chrome 49.
As a side note, another SO answer (https://stackoverflow.com/a/26003382/634650) suggested using:
supportsDataUri = 'download' in document.createElement('a');
This works in IE but not Edge.
Update
The SO answer above also includes a link to a SO answer referencing a Modernizr issue about feature detection for data URI in iframe support. Opening a data URI in an iframe is basically the same thing as opening one in a new windows and the Microsoft browsers which do not support data URIs in iframes don't support opening them in new windows. Additionally, the test for the iframe support mentioned in those locations is synchronous so I would recommend using it instead of my async solution.
It is weird that even Microsoft Edge is not supporting the data URI. Older versions of IE only allows base64 encoded images of up to 32KB. I had come across a reference link lately which relates to the similar issue you have mentioned with Moderinzr.
Does modernizr check for data uri's?#294
It appears they have added a patch for the issue. It is a data URI test.
This post has the similar answer regarding the issue. I hope these fixes should work throughout.

file upload not working on internet explorer 8 and 9

function uploadFile(){
var file = $("file1").files[0];
var formdata = new FormData(); formdata.append("file1", file);
var ajax = new XMLHttpRequest();
ajax.upload.addEventListener("progress", progressHandler, false);
ajax.addEventListener("load", completeHandler, false);
ajax.addEventListener("error", errorHandler, false);
ajax.addEventListener("abort", abortHandler, false);
ajax.open("POST", "upload.php";
ajax.send(formdata);
}
Error1: Unable to get value of the property '0': object is null or undefined
Error2: ForData not supported.
The FormData API is not supported by IE8 or IE9. It was only added in IE10. If you want to support these old browsers, then you cannot use modern HTML5 APIs.
There is a jQuery Forms plugin which does work in old IE versions and can allow you to upload files via ajax. I've used it myself and it is very effective. You can download it here: http://malsup.com/jquery/form/. You will probably need to rewrite your code a fair bit in order to use it as it's quite different conceptually to the HTML5 FormData API, but at least you'll get something that will work across all the browsers you want to support.
You could also try looking to see if there's a polyfill for FormData which would allow you to keep using your existing code. A quick google turned up this one, which I found listed here. I haven't tried it so can't vouch for it, but the polyfills listed by Modernizr on that list are generally pretty good.

Instanciate Firebreath plugin via JS in IE8

I'm trying to instanciate a plugin made with Firebreath in Internet Explorer 8 but with no luck so far. This is the code that I'm using:
try
{
if(window.ActiveXObject)
{
var plugin = new ActiveXObject("my.plugin");
return true;
}
else
return false;
}
catch(e)
{
return false;
}
This works fine if I put this code in a html page and then open it from disk (also published in my local IIS); but as soon I publish it (it's a facebook application, so, running inside an IFRAME) I get this message (from the catch exception):
Automation server can't create object
I've tried messing around with IE security zones, but nothing happens, always the same message. Is there any workaround for this? I need to be able to get the plugin version (coded inside the plugin).
Thank you!

Cross-subdomain AJAX works in Chrome, not IE

I have a local build of my site running at local.mydomain.com. I'm making ajax requests to api.mydomain.com which is running on an AWS server and returns JSON. In Chrome, I can call the API no problem. But in IE, I get Access Denied.
After researching, it seems to be a cross-(sub)domain restriction. But I was under the impression that this restriction would apply to both browsers. Can anybody see what might be going wrong here and why it might work in some browsers and not others?
It looks like the problem was in the transport object that IE8+ wants you to use. jQuery uses either ActiveXObject (for IE) or XMLHttpRequest (all others), but IE 8 and above requires XDomainRequest for ajax.
What you can do is return a custom xhr object via $.ajaxSettings.xhr like this,
// override xhr for browser that use XDR
if ('XDomainRequest' in window && window.XDomainRequest !== null) {
// override default jQuery transport
jQuery.ajaxSettings.xhr = function() {
try { return new XDomainRequest(); }
catch(e) {
console.log('test');
}
};
// also, override the support check
jQuery.support.cors = true;
}
I pulled this code from a discussion on the subject here:
http://graphicmaniacs.com/note/getting-a-cross-domain-json-with-jquery-in-internet-explorer-8-and-later/
Definitely take a look at that if you think you're experiencing the same problem.

Issues in Getting RSS/ATOM using javascript

I know this is a much discussed topic.. But I am facing an issue I am not finding answer to.. I am using AJAX to load the feed. I know it reads from the .xml extension, but not all rss links end in .xml.
I know there is google API, also rss2js etc, but I am not allowed to use it, nor can I use a javascript library like jQuery, prototype..
here is the code:
if (window.XMLHttpRequest){
xmlhttp=new XMLHttpRequest();
} else {
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200){
//yet to add code to parse it...
document.getElementById("myDiv").innerHTML=xmlhttp.responseXML;
}
}
xmlhttp.open("GET","http://wordpress.org/support/rss/topic/how-to-get-xml-address-of-wordpress-rss-feed",true);
xmlhttp.setRequestHeader('Connection','close');
xmlhttp.send(null);
that blog post is not mine, neither do I wish to advertise it.. :) found it while I was searching for the answer, included to make my problem more explanatory..
When I enter that url in the browser, it shows me some posts.. But the code returns nothing.. Also checked using the net panel of firebug(firefox extension), nothing returned.
Its not wordpress RSS I want(they have an API), consider it replaced with any other feed url..
Where am I going wrong in that code..?
You're attempting to read data from another domain name to the one your script is hosted on, which is forbidden by most browsers for security reasons.
There are a few workarounds for this limitation, but they're not especially straightforward.

Resources