I have some JQuery and JavaScript code that works in Chrome and Firefox but not IE. The code is nested inside of SAS and I removed the SAS nesting. Does anyone see a reason why this code would error out in IE? related. I am using IE 11. I am getting the error: document.addEventListener( "DOMContentLoaded", completed, false );
<script type="text/JavaScript">
function saveMultiSelection(pageName) {
document.getElementById('save_degStudLevComma').value = $(""#degStudLev"").multipleSelect('getSelects');
document.getElementById('save_studyLevelComma').value = $(""#studyLevel"").multipleSelect('getSelects');
document.getElementById('save_sumLevComma').value = $(""#sumlev"").multipleSelect('getSelects');
document.getElementById('save_awardTypeComma').value = $(""#awardType"").multipleSelect('getSelects');
}
</script>
Why you don't use jquery all the way if you have it in your app already?
function saveMultiSelection(pageName) {
//(...)
$('#save_degStudLevComma').val($("#degStudLev").multipleSelect('getSelects'));
//(...)
}
You can see broswer support version -> https://developer.mozilla.org/en-US/docs/Web/Events/DOMContentLoaded
IE support = 9+ ->DOMContentLoaded
Related
Ok so the code below works on every browser except ios chrome and IE.
What changes can be made to make it compatible with those browsers
<script type="text/javascript">
!function(){
var campaign_link = "http://example.com/time&"; // REPLACE WITH YOUR LINK
var t;
try{
for(t=0;10>t;++t)history.pushState({},"","#");
onpopstate=function(t){t.state&&location.replace(campaign_link)}}
catch(o){}
}();
</script>
You are getting the error because of history API. Its not supported in sme browsers
All versions below Internet Explorer 9 definitely does not support history.pushState() or history.popState()
iOS has a fair few bug with the HTML5 History API.
You can try like :
window.addEventListener("popstate", function(e) {
window.location.href = location.href;
});
I am developing an app for social network which works in IFrame. The app works just fine in Google Chrome and Microsoft Firefox browsers, but in Opera 12.15 JQuery library v1.10.1 fails to load with security error Unhandled error: Security error: attempted to read protected variable on line 1513.
The screenshot is here:
It looks like the same bug exists in Internet Explorer 10.
How to deal with it?
UPDATE:
I have made dirty hack by commenting the lines 1513-1517 in the code of jquery:
// Support: IE>8
// If iframe document is assigned to "document" variable and if iframe has been reloaded,
// IE will throw "permission denied" error when accessing "document" variable, see jQuery #13936
/*if ( parent && parent.frameElement ) {
parent.attachEvent( "onbeforeunload", function() {
setDocument();
});
}*/
The functionality of my app seems to work now, maybe it is necessary to create issue in JQuery repo...
Bug report was created - http://bugs.jquery.com/ticket/13980.
Bug is now fixed.
Add this before you include JQuery:
var isIE11 = !!(navigator.userAgent.match(/Trident/) && !navigator.userAgent.match(/MSIE/));
if (isIE11) {
if (typeof window.attachEvent == "undefined" || !window.attachEvent) {
window.attachEvent = window.addEventListener;
}
}
Hope it helps, It worked for me.
I'm using
$(upload_button).bind('change', function(event)
{
var files = this.files;
alert(typeof(files));
if(typeof(files)!='undefined')
{
}
});
in my code with jQuery which is working fine in Firefox and Chrome but not in IE8(i.e., IE returns undefined for files.length, whereas others returns the value). So do anybody know how to resolve this?
That's because Internet Explorer, even IE9 does not support HTML5 File API and therefore it returns undefined value for files property.
From jQuery API.
change event will not work with button as I am assuming upload_button is button.
I have a queastion about ActiveXObject in javascript. I have tryed this code in Mozila FireFox 6.0.2
var AXobj = new ActiveXObject("WScript.Shell");
AXobj.SendKeys(key);
But the error console says that ActiveXObject is undefined. After that, I have tryed this:
var AXobj = new DOMParser("WScript.Shell");
AXobj.SendKeys(key);
But then, the error console says:
Error: uncaught exception: [Exception... "Security error" code: "1000" nsresult: "0x805303e8 (NS_ERROR_DOM_SECURITY_ERR)" location: "file:///C:/Documents%20and%20Settings/Guest/Desktop/stuff/html/GML%20to%20JS.html Line: 335"]
By the way, i don't want to use ActiveXObject only for SendKeys. I need it for more stuff (like writing in file... ) AND, the reason i use FireFox instead of IE is that FireFox supports HTML5.
ActiveX is a proprietary technology only supported by Microsoft...
It will only work in IE (thank goodness).
It also has some serious security concerns which is a big reason it was never adopted by other browser providers.
For this you can check if it is IE then do this otherwise
do that.
Like:
Function exampleFunction()
{
if ($.browser.msie) { /* IE */
//Your code
else {
//Your code
}
}
just a suggestion.
I'm seeing this issue in Internet Explorer 8, but not in Safari or Firefox. So far, I have not tested in other IE versions.
I am developing my own jQuery plugin and, for this question, I've stripped it down to the two relevant lines.
In IE 8, using the code below, $('title').text() does not do anything. docTitle is blank because title is blank, as if the jQuery selector for <title>, $('title') is not working. (Again, AFAIK, this is just in IE 8)
(function ($) {
$.fn.myPlugin = function (options) {
var title = $('title').text(),
docTitle = escape(title);
};
})(jQuery);
http://jsfiddle.net/sparky672/YMBQ2/
However, using the plain JavaScript code below, document.title is working fine in everything including IE 8...
(function ($) {
$.fn.myPlugin = function (options) {
var docTitle = escape(document.title);
};
})(jQuery);
EDIT:
It does not matter that this code is inside a plugin.
Same result in IE 8 with this...
$(document).ready(function () {
var title = $('title').text();
alert(title);
});
Just to clarify, I am not insisting on using this. In fact, I fixed my plugin by simply using document.title instead. If it wasn't clear initially, I'm just asking why this does not work in IE 8.
Can anyone explain why, or what stupid mistake I may have made here?
EDIT 2:
Here are some jQuery Bug reports on this issue
http://bugs.jquery.com/ticket/7025
http://bugs.jquery.com/ticket/5881
http://bugs.jquery.com/ticket/2755
And dozens of others reporting the same thing. The official response is to state, "document.title is the only reliable cross-browser way and should be used instead" and the Ticket is closed. So there you go.
I guess jQuery iterates over all TextNodes and concatenates its nodeValue. IE stores this value differently than other browsers.
var title = document.getElementsByTagName('title')[ 0 ];
title.firstChild // This would be the Text-Object with the characterdata of the title
// Firefox: [object Text]
// IE: null
This should be the reason you cannot get the textContent with jQuery.text(). title.text seems to be cross browser comp. I only tested it in IE 7 and Firefox 3.6 but you can check the other browser if you like. But why not using document.title?
try using $('title').html() which should work in all browsers