You are here: Possible to read JavaScript results into a string? « PHP « IT news, forums, messages
Possible to read JavaScript results into a string?

Posted by Brian Dunning on 10/04/34 11:23

I have an external JavaScript that I use on several of my sites. It
returns a web counter and does some other logging. It's accessed like
this:

<script language="javascript" src="http://www.mydomain.com/log.js"></
script>

No rocket science there, this is common and it works great. That call
returns a block like this:

document.write('<a bunch of html>')

What I want to know is: is it possible to retrieve the above
outputted code into a string, rather than outputting it directly to
the browser? Nothing I've tried works, and I also tried this using a
Google AdSense call to make sure there was not a problem in my
JavaScript. Here's what I tried and what happened:

<?php
$x = file_get_contents('http://www.mydomain.com/log.js');
// also tried urlencode() but that did not help
?>

The result:

Warning: main(http://www.mydomain.com/log.js) [function.main]: failed
to open stream: HTTP request failed! HTTP/1.1 400 Bad Request in c:
\Inetpub\wwwroot\test.php on line 2

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация