Add CSS rules at runtime in IE6 - Object doesn't support this property or method

Trying to get my site running in IE6 but having trouble with some runtime css stuff that I need to do.

I've tried both these:

$.rule('#post'+ i + '{ visibility:hidden;}').appendTo('style');

-

var postStyle = document.createElement('style');
postStyle.type = 'text/css';    
postStyle.innerHTML = '#post'+ i + '{ visibility:hidden;}';
document.getElementsByTagName('head'[0].appendChild(postStyle);

Works in other browsers but not IE. I get this error:

"Object doesn't support this property or method"

Any ideas?

Answers


I've provided cross-browser code to do this before on Stack Overflow. Here's one example:

https://stackoverflow.com/a/3922317/96100


In IE, you have to do this:

postStyle.styleSheet.cssText = whatever;

I've done this generally with a try/catch setup.

$('head').append($('<style/>', { id: "replaced-colors" }));

try {
  $('#replaced-colors').html(replaced);
}
catch (_ie) {
  $('#replaced-colors')[0].styleSheet.cssText = replaced;
}

as a real-life example.


Need Your Help

2 way SSL between nginx and backend server

node.js ssl nginx

I have a backend server on Node.js and I am trying to setup 2 way SSL between Nginx and this backend server.

Can I protect against SQL Injection by escaping single-quote and surrounding user input with single-quotes?

sql security sql-server-2000 sql-injection sanitization

I realize that parameterized SQL queries is the optimal way to sanitize user input when building queries that contain user input, but I'm wondering what is wrong with taking user input and escaping...