This is intended as crude workarounds for filling jQuery specifically in IE 5.5. Note, this is not intended to be a comprehensive solution nor is it aimed at supporting both legacy browsers and modern browsers.
Created
April 29, 2012 21:21
-
-
Save johntimothybailey/2553326 to your computer and use it in GitHub Desktop.
Polyfills for jQuery to work in IE5.5
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jQuery.fn.append = function( ) { | |
var element = this.get(0); | |
var appending = arguments[0]; | |
if( appending.charAt(0) === "<" ){ | |
throw Error("This appears to be a dom element represented as a string. Please create the element then append"); | |
} else{ | |
// Wonder if there is a better way to do this | |
element.innerHTML = element.innerHTML + appending; | |
} | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jQuery.fn.isString = function ( value ){ | |
return typeof value === "string"; | |
} | |
// I would rather like to know why jQuery.access fails silently in IE 5.5. In the meantime, this resolves the issues of accessing attributes. | |
jQuery.fn._attr = jQuery.fn.attr; | |
jQuery.fn.attr = function ( ) { | |
var key = arguments[0]; | |
if(arguments.length == 1) { // Perform a get | |
this.get(0).getAttribute(key); | |
}else{ | |
this.get(0).setAttribute(key,arguments[1]); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jQuery.fn.prepend = function( ) { | |
var element = this.get(0); | |
var appending = arguments[0]; | |
if(typeof appending === "string"){ | |
if( appending.charAt(0) === "<" ){ | |
throw Error("This appears to be a dom element represented as a string. Please create the element then prepend"); | |
} else{ | |
// Wonder if there is a better way to do this | |
element.innerHTML = appending + element.innerHTML; | |
} | |
}else{ | |
element.insertBefore(arguments[0]); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment