Bitweiser
04-20-2009, 08:13 AM
Hello, I'm confronted with a problem. I'm trying to include PHP on servers that won't allow PHP. I have two servers, one without PHP and one with PHP.
For this I've written a Include funtion in javascript.
<script type="text/javascript">
function include(file) {
if (document.createElement && document.getElementsByTagName) {
var head = document.getElementsByTagName('head')[0];
var script = document.createElement('script');
script.setAttribute('type', 'text/javascript');
script.setAttribute('src', file);
head.appendChild(script);
} else {
alert('Your browser can\'t deal with the DOM standard. That means it\'s old. Go fix it!');
}
}
</script>
This script is called in de body-section of the non-php document.
<script type="text/javascript">include('http://a-php-server/include.php');</script>
At the php-end I have only one line:
<?php echo "alert('some text');"; ?> ==> This works. My main document shows an alert with some text.
Now, when I replace the alert with a document.write like so:
<?php echo "document.write('yo yo yo yo');"; ?> ==> Nothing happens. No text is displayed. WHY??
Thanx...
For this I've written a Include funtion in javascript.
<script type="text/javascript">
function include(file) {
if (document.createElement && document.getElementsByTagName) {
var head = document.getElementsByTagName('head')[0];
var script = document.createElement('script');
script.setAttribute('type', 'text/javascript');
script.setAttribute('src', file);
head.appendChild(script);
} else {
alert('Your browser can\'t deal with the DOM standard. That means it\'s old. Go fix it!');
}
}
</script>
This script is called in de body-section of the non-php document.
<script type="text/javascript">include('http://a-php-server/include.php');</script>
At the php-end I have only one line:
<?php echo "alert('some text');"; ?> ==> This works. My main document shows an alert with some text.
Now, when I replace the alert with a document.write like so:
<?php echo "document.write('yo yo yo yo');"; ?> ==> Nothing happens. No text is displayed. WHY??
Thanx...