is top.document cross browser? - javascript

I'm writing a javascript that relies on top.document but I'm not sure if I can assume all the major browsers supports it or not.
Is top.document cross-browser compatible?

According to W3Schools, window.top is supported in IE (since v4), FF (v1), and Opera (v9). I can personally vouch for it working in Safari as I just tried their example code in my own browser. :-)

I've never used it, but I believe it is.
Nested frames are so passe.
Check out this handy Quirksmode article on the topic.

Related

Crypto.getRandomValues Implementation for IE9 and Firefox

I am looking for an implementation of crypto.getRandomValues to use it in the Internet Explorer 9 and Firefox. From my basic knowledge of JS/HTML this are not available in those browser.
any idea?
The best example I can find is alert(window.crypto.getRandomValues(new Uint8Array(2))[1]). This will work great for firefox and chrome- but not IE. You'll have to use a third party library such as Clipperz and check to see its compatibility if you want randomness on all three.

How to make JS and CSS compatible with IE, Firefox, Chrome, Safari?

Our company develops ERP and CRM, and so far our products support IE and Firefox. Now we want to support Chrome, Safari and even Opera. Is there any comprehensive materials that introduce browser compatibility of JS and CSS? thks!
theres the mozilla dev-center that has a great CSS- and JavaScript-reference. Every entry has information about browser compatibility.
For a quick overview, you cauld also take a look at caniuse.com (CSS and JavaScript) that provides simple tabular lists for the different features.
I've been coding the front-end for over a decade and a half now, and things seem to get better over time in regards to cross-browser compatibility. I've found that if I write and test my code using Firefox, most everything will work flawlessly on Chrome, Opera, Safari and the only thing you'll end up having to debug would be MSIE. 10 years ago I would have told you to code and test using MSIE and debug your code in the end with Netscape.
But yeah, if you follow this, you'll find it easier to make all your scripting and markup fully cross-browser compatible with no bugs at all. Enter IE9, of course, a different monster altogether.
Is there any comprehensive materials that introduce browser
compatibility of JS and CSS?
http://en.wikipedia.org/wiki/Comparison_of_layout_engines_(Cascading_Style_Sheets)
http://html5test.com/
http://caniuse.com/
"Comprehensive" can change overnight, but there is a great deal of information available.
If your products work for the latest version of Firefox, Chrome, Safari, and Opera will work without major flaws most of the time. If your markup is invalid, you are using many vendor-specific extensions, or you are using cutting-edge features, this may not be the case.

What browsers support the window.postMessage call now?

What are all the browsers that support the window.postMessage call now? I am looking for browsers that support it natively, not through an iFrame hack.
Can I use cross-document messaging
FF3+, IE8+, Chrome, Safari(5?), Opera10+
IE8 does not allow postMessage across windows/tabs
http://blogs.msdn.com/b/ieinternals/archive/2009/09/16/bugs-in-ie8-support-for-html5-postmessage-sessionstorage-and-localstorage.aspx
for more info check here
http://www.openajax.org/member/wiki/Browser_Variation_of_the_Hub_Reference_Implementation_%28Illustrative%29
postMessage is supported in IE8+ HOWEVER
Remember that IE9 and below require data to be passed in string form and not as an object.
IE doesn't like you to call postMessage as soon as page loads (I'm assuming this has to do with the iframe you are posting to needing time to load).
Use a setTimeout to wait one or two seconds before calling postMessage.
It took me hours to figure this out and IE wasn't giving me any error message, it was just silently doing nothing until I added the setTimeout.
If you want to start with a demo which actually does work in IE, check out this nifty tutorial by Ilya Kantor
For what it's worth recently I ran into some odd webkit browser/versions out in the wild that did NOT support postMessage. I was using IE(8) detection as my means for seeking an alternative. Instead, I probably should have just done some something like this:
if(window.postMessage){
console.log('Supports post message');
}
Or likely a bit cleaner:
var pm_is_supported = typeof(window.postMessage) == 'function';
All latest browsers supports that e.g. IE 11, Edge, Firefox 57+, Dafari 11+, iOS Safari 10.2+, Opera mini, Chrome for android, UC Browser etc.
https://caniuse.com/#search=document%20messaging

document.getElements() support

How well supported is the document.getElements() function. Additionally, is there a javascript reference page that has detailed browser support information somewhere. I usually use the mozilla docs, but I was wondering if there is something better.
I actually can't find any documentation on document.getElements() but when I do things like:
document.getElements("div a");
It works great in chrome, ff, safari, ie8 and ie6-9 via IETester. I think IETester may use the same javascript engine for all browsers though (not sure about that).
There is no such thing as document.getElements... I'll bet your coding in Jsfiddle and don't realize that the mootools lib is included ;)
Have a look:
http://jsfiddle.net/Zevan/pRKzy/
quirksmode.org is a pretty good resource for things like this (though not fully updated on IE9, as it's a moving target at the moment).
Note: they don't have an entry for document.getElements() specifically (are you sure you're getting this name right?), but in general it's a pretty complete reference, here's an example - check out .querySelectorAll() (which does what you describe...).
Probably you are looking for querySelecterAll function:
elementList = parentNode.querySelectorAll(selectors);
This is most handy and much usable function.
To check how your requested feature is supported among browsers you can use "Can I Use" site:
https://caniuse.com/#search=querySelectorAll
On this site you can check not only functions but HTML attributes and CSS capabilities too

If you take IE out of the picture what additional JavaScript functionality is available in the other browsers?

I'm just talking about JavaScript here, not CSS or implementation of the DOM.
I know getters and setters are now available in the latest release of all major browsers except IE. What other JavaScript features are available cross-browser if we have the latest versions of the other browsers and forget about IE for a minute?
With Gecko-engined browsers, you get:
https://developer.mozilla.org/en/New_in_JavaScript_1.6
https://developer.mozilla.org/en/New_in_JavaScript_1.7
https://developer.mozilla.org/en/New_in_JavaScript_1.8
In terms of other browsers implementing these features, I'm only aware of Webkit implementing Array Extras, but it's actually quite easy to monkeypatch support for those in all browsers since they're just additional methods.
Gecko, Opera and Webkit also support the canvas element, which although being a new HTML element, is used via JavaScript, so I'm not sure if that fits your criteria. Having said that, there are independent efforts underway to bring it to IE.
I would recommend you visit www.quirksmode.org for a lot of detailed comparisons of different browsers/versions.
XML APIs:
DOMParser object
XMLSerializer object
XSLTProcessor object
DOM XPath implementation
Although these are not "JavaScript functionality", rather DOM APIs

Categories