Geoff Wilkins wrote:
I am using <SCRIPT src=...> to import a Javascript routine from a remote
source. I am then using some of the variables given values in the
routine, in my own Javascript..
Unfortunately the routine also outputs to the page using document.write.
I don't want this output. Any ideas how I can get rid of it?
I am not sure you need that as you could take the script from the src
and rewrite it as necessary but if needed you can disable document.write
temporarily to a function doing nothing and then restore it later:
<html>
<head>
<title>disabling document.write</title>
<script type="text/javascript">
function disableDocWrite () {
document.oldDocumentWrite = document.write;
document.write = function () {};
}
function enableDocumentWrite () {
document.write = document.oldDocumentWrite;
}
disableDocWrite();
</script>
<script type="text/javascript">
// this would be the external script to be loaded with
// script src, to have a complete example I have simply used
// an embedded script here
function getGOD () {
var GOD = 'Kibo';
document.write('All praise ' + GOD + '.');
return GOD;
}
</script>
<script type="text/javascript">
var GOD = getGOD();
alert(GOD);
enableDocumentWrite();
</script>
</head>
<body>
<h1>document.write test</h1>
<p>
<script type="text/javascript">
document.write('Kibology for all.');
</script>
</p>
</body>
</html>
--
Martin Honnen
http://JavaScript.FAQTs.com/