I have two websites: domain1.com and domain2.com.
The script on domain1.com/external.php is:
<?php
echo <<<ots
<!--
document.write('Hello World!');
//-->
ots;
?>
I want to execute this external.php script on domain2.com, so I use:
<script src="http://domain1.com/external.php"></script>
The problem is - the Javascript often hangs out, so I wanted to include the < script.. right below the < /body>. However, I must print the Hello World! text in a specific place on the page (ie. right after the </head>).
Question - can I include the < script.. right below the < /body> to assign the output somehow and then put this variable on the page after the script executes?
Or any other similar solution? I cannot use JQuery.
document.getElementById('idOfTarget').innerHTML='Hello World!';See also this answer.echopart?document.writewill destroy the page's content if the document is already closed. You should consider Petr's suggestion.