Www.page-test.co.uk/ie.html works on every browser except IE 7/8


The above small script (couple of lines) works in every browser except IE7/8.

Is there an alternative?

Btw. A framework I use passes values from PHP to the client using this method.

The problem is that the ternary operator doesn’t work in IE7/IE8 with an undeclared variable.
You can test this by adding

var value_a = "";
var value_b = "";

to the beginning of your script, then as you will see, everything works as expected in IE7/IE8.

However, this is probably not the ideal solution.
Maybe you could do it like this instead:

var value_a = (document.getElementById( 'value_a' )) ? document.getElementById('value_a').content : "";
var value_b = (document.getElementById( 'value_b' )) ? document.getElementById('value_b').content : "";

This should work in all browsers.