Tuesday, June 4, 2024
 Popular · Latest · Hot · Upcoming
138
rated 0 times [  140] [ 2]  / answers: 1 / hits: 27098  / 14 Years ago, mon, june 21, 2010, 12:00:00

I want to remove this Google Analytics block, using jQuery.



<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>
<script type=text/javascript>
try {
//var pageTracker = _gat._getTracker(xxx);
pageTracker._trackPageview();
} catch(err) {}
</script>


THE REASON



Because I am creating a bespoke screen reader convertor for jQuery based on a client specification. It's the Google Analytics that is bugging me.



THE PROBLEM



It works with .remove() until you navigate away, then press back. Google Analytics hangs.


More From » jquery

 Answers
4

Try this:



var replacementDoneIn = $(document.body).text(); //remove Google Analytics document.write line
var regExMatch = /document.write(unescape/g;
var replaceWith = //document.write;
var resultSet = replacementDoneIn.replace(regExMatch, replaceWith);
$(body).html(resultSet);


Hope that helps!


[#96436] Thursday, June 17, 2010, 14 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
kileyr

Total Points: 112
Total Questions: 105
Total Answers: 114

Location: United States Minor Outlying Island
Member since Sat, May 28, 2022
2 Years ago
;