Just getting off my JavaScript training wheels.
Why does Google choose to unescape
the document.write
line in Part 1 below?
Why don't they just write it like this? Maybe unescape
is required for some older browser compatibility?
document.write('<script src="'
+ gaJsHost
+ 'google-analytics.com/ga.js" type="text/javascript"></script>');
For reference, the entire Google Analytics tracking code looks like this:
Part 1:
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol)
? "https://ssl."
: "http://www."
);
document.write(unescape("%3Cscript src='"
+ gaJsHost
+ "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"
));
</script>
Part 2:
<script type="text/javascript">
try
{
var pageTracker = _gat._getTracker("UA-0000000-0");
pageTracker._trackPageview();
}
catch(err){}
</script>
I understand what the rest of the code does, just curious about the unescape part.
Edit
The bottom line is, unescape
is required. Voted to close this question because it is a duplicate (see answer marked correct).