Website blank when using Piwik

Hi

Have been using Piwik for some time now. I recently added the following jQuery code to a website


$(document).ready(function () {
    var replaced = $("body").html().replace(/my_val/g,'replace_val');
    $("body").html(replaced);
});

The code globally replaces ‘my_val’ with ‘replace_val’ within the body of a web page once the document has completed loading. By design, all instances of ‘my_val’ are within links, e.g., http://www.mysite.com/page.php?myvar=my_val

Now, in IE, the website loads, goes blank and the page source is replaced with


<script src='http://mypiwikstatsdomain/piwik.js' type='text/javascript'></script>

The above is the only thing visible when viewing the page source. In Firefox the page simply hangs.

When the jQuery code is removed the page loads as expected. For now I have removed Piwik from the site but would appreciate any insight into whether there is something I could do (have only tried deactivating plugins so far).

Regards.

I dont think it’s correct to do this global replace on the body of the document, as I believe it screws the DOM event bindings and possibly other things. try another solution to replace the text…

Thanks. Sometimes it just needs to be said in a clear way like this :slight_smile:

A global replace was not the correct approach to take for the reasons you mentioned. Things are now working as perfectly as they were before (tu).