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?
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.
In case anyone run into this problem in the future, to stop the analytic code from being included, all you have to do is use the exit() command at the end of your script. The code is in a PHP auto-append file. It doesn't get executed if you exit explicitly instead of letting the script reach the end of the file. The setup at 000webhost.com parses HTML through PHP as well. If you want your regular HTML files to pass validation, add at the very end the following:
<?php exit; ?>
Adding to Catfish's answer,
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.
As asked by asalamon74 in the comments,
When I disable the analytics code with this method my domain get canceled due to inactivity. Is there a way to avoid it
Yes, there is a simple way to avoid it. Go ahead and enable your analytics code. Visit http://members.000webhost.com/analytics.php and enable it again.
Then, create a .htaccess
in your public_html
folder and add the following code to it:
<FilesMatch "\.(php)$">
php_value auto_append_file none
</FilesMatch>
This will prevent all .php
files from been appended with the analytics code. Just replace php
with any file extension where you want the analytics code removed.
That's all. This way your domain won't get cancelled. Hope it helps.
According to the FAQ, you can go to http://members.000webhost.com/analytics.php to disable the analytics:
FAQ - Frequent Ask Questions Guide!:
http://www.000webhost.com/forum/faq/7894-faq-frequent-ask-questions-guide.html
Alternatively, you could edit your .htaccess
file by adding this line:
php_value auto_append_file none
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:
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With