toString() and IE

Gold Contributor
Gold Contributor
hi, I know that utag.js use ".toString()" method (i.e. with load rules), but I also know that IE does not support that method, so I guess that in many cases utag.js stops running due to IE-error. Does it make sense on you? Do you have any evidence of that? Or am I wrong? Thanks,
7 REPLIES 7
Moderator
Moderator
Hi Jarno, IE does support the toString method. However, your load rule may fail if it attempts to do a toString on an undefined variable e.g. if your load rule says "page_name contains ignore case 'test'", then if page_name is not defined, you'll get an uncaught error: "Cannot call method toString of undefined" or something similar. To avoid this, it's best to add a check to the load rule that the variable is defined before trying to perform a comparison on it: i.e. "page_name IS DEFINED AND page_name contains_ignore_case 'test'". I hope this helps to explain what's going on. Craig.
Check out our new Swift integration library for iOS, macOS, tvOS and watchOS: https://github.com/Tealium/tealium-swift with updated
documentation https://community.tealiumiq.com/t5/Swift/tkb-p/swift.
Tealium Employee
Hi Jarno, toString() is support from IE6 up. Please see documentation about this on the IE Dev Centre: http://msdn.microsoft.com/en-us/library/ie/k6xhc6yc(v=vs.94).aspx Hope this helps. Kind Regards Simon

toString() and IE

Gold Contributor
Gold Contributor
Ok thanks.
Gold Contributor
Gold Contributor
Great, I see now... So it's a good practice to add a "DEFINED" or "NOTDEFINED" condition at the beginning of any load rules? otherwise we occur in the following problem: we need to load a Z tag when X does not contain Y. If X does not exist, the condition is TRUE, but we get an javascript error instead.
Moderator
Moderator
Correct - if you're testing for a value in a variable, it's a good idea to make sure it is defined first. Adding the DEFINED check will protect against the case where your variable does not exist.
Check out our new Swift integration library for iOS, macOS, tvOS and watchOS: https://github.com/Tealium/tealium-swift with updated
documentation https://community.tealiumiq.com/t5/Swift/tkb-p/swift.
Tealium Employee
IS POPULATED is also a good one. It checks for the data source is defined AND it has a value.

toString() and IE

Gold Contributor
Gold Contributor
great tip!
Public