Webhoster inserts a javascript which brokes my code how to remove it?

Viewed 20116

I use the free webhost 000webhost. The service is okay but it inserts some javascript counter into every file and request. The script looks like this.

<!-- www.000webhost.com Analytics Code -->
<script type="text/javascript" src="http://analytics.hosting24.com/count.php"></script>
<noscript><a href="http://www.hosting24.com/"><img src="http://analytics.hosting24.com/count.php" alt="web hosting" /></a></noscript>
<!-- End Of Analytics Code -->

If i do a jquery post it breaks my code and I get no response.

<?xml version="1.0"?>
<response>
 <status>1</status>
 <time>1266267386</time>
 <message>
  <author>test</author>
  <text>hallo</text>
 </message>
 <message>
  <author>test</author>
  <text>hallo</text>
 </message>
 <message>
  <author>test</author>
  <text>hallo</text>
 </message>
 <message>
  <author>test</author>
  <text>hallo</text>
 </message>
 <message>
  <author>admin</author>
  <text>hallo</text>
 </message>
</response>
<!-- www.000webhost.com Analytics Code -->
<script type="text/javascript" src="http://analytics.hosting24.com/count.php"></script>
<noscript><a href="http://www.hosting24.com/"><img src="http://analytics.hosting24.com/count.php" alt="web hosting" /></a></noscript>
<!-- End Of Analytics Code -->

How can I fix that? How can I remove the hosting javascript code?

9 Answers

They have a link in their cPanel where you can disable the analytics code.

http://members.000webhost.com/analytics.php

EDIT

Beware - by doing this you violate their policy and they will eventually drop you from their service and you will lose all your data.

Try changing the content-type in PHP; that should help. (For example, I assume, it doesn't modify images)

Alternatively, you could remove the code in Javascript using indexOf and substring.

Check the terms of service agreement for your host. They may require their analytics code to run unadulterated as part of your TOS.

If they require this code to run, then there are 2 possible solutions:

  • Get a new host (see http://www.webhostingtalk.com for hosting reviews and deals)
  • Figure out what in your code is being affected and find a work around there.

If they do not require the analytics code block as a condition of service then you may be able to block their snippet from running by altering the tag's event handler via jquery that they use to fire their code.

If you are using the $.ajax(); function, there is a dataFilter parameter that lets you modify the raw contents of the request before processing it. In here, you could either substring or replace out the offending text, or you could add a <!-- to the end of your XML file, then stick a --> at the end of the response in the dataFilter code.

I had EXACTLY the same problem with these guys. I was so confounded as Chrome just said there was a problem, but thankfully I tried Firefox and it actually blurted out the offending code. I talked to customer support about it, and they said they don't add content to customer pages. Seriously?! So the solution is, as suggested by others, move on and get someone better.

Related