adding custom functions into Array.prototype

While the potential for clashing with other bits o’ code the override a function on a prototype is still a risk, if you want to do this with modern versions of JavaScript, you can use the Object.defineProperty method, e.g. // functional sort Object.defineProperty(Array.prototype, ‘sortf’, { value: function(compare) { return [].concat(this).sort(compare); } });

IE crossing out pseudo element CSS?

This is a known issue, but the styles are in fact being applied. The developer tools thinks the pseudo-element styles are being overridden by the parent-elements corresponding styles. This is easily demonstrated by inspecting the Computed style of the parent-element and looking at (what the F12 tools believe to be) competing styles: Again, however, these … Read more

How to forcefully set IE’s Compatibility Mode off from the server-side?

I found problems with the two common ways of doing this: Doing this with custom headers (<customHeaders>) in web.config allows different deployments of the same application to have this set differently. I see this as one more thing that can go wrong, so I think it’s better if the application specifies this in code. Also, … Read more

How can I detect Internet Explorer (IE) and Microsoft Edge using JavaScript?

Here is the latest correct way that I know of how to check for IE and Edge: if (/MSIE 10/i.test(navigator.userAgent)) { // This is internet explorer 10 window.alert(‘isIE10’); } if (/MSIE 9/i.test(navigator.userAgent) || /rv:11.0/i.test(navigator.userAgent)) { // This is internet explorer 9 or 11 window.location = ‘pages/core/ie.htm’; } if (/Edge\/\d./i.test(navigator.userAgent)){ // This is Microsoft Edge window.alert(‘Microsoft … Read more

MSIE and addEventListener Problem in Javascript?

In IE you have to use attachEvent rather than the standard addEventListener. A common practice is to check if the addEventListener method is available and use it, otherwise use attachEvent: if (el.addEventListener){ el.addEventListener(‘click’, modifyText, false); } else if (el.attachEvent){ el.attachEvent(‘onclick’, modifyText); } You can make a function to do it: function bindEvent(el, eventName, eventHandler) { … Read more

Code with classList does not work in IE?

The classList property is not supported by IE9 and lower. IE10+ supports it though. Use className += ” ..” instead. Note: Do not omit the space: class names should be added in a white-space separated list. var img = new Image(); img.src=”https://stackoverflow.com/image/file.png”; img.title=”this is a title”; img.className += ” profilePic”; // Add profilePic class to … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)