473,670 Members | 2,551 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Can one divert or hide document.write output?

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?

--
Best wishes,

Geoff Wilkins
Ge****@wordsmit h.demon.co.uk
Jul 20 '05 #1
2 3540


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>disablin g document.write</title>
<script type="text/javascript">
function disableDocWrite () {
document.oldDoc umentWrite = document.write;
document.write = function () {};
}
function enableDocumentW rite () {
document.write = document.oldDoc umentWrite;
}
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);
enableDocumentW rite();
</script>
</head>
<body>
<h1>document.wr ite test</h1>
<p>
<script type="text/javascript">
document.write( 'Kibology for all.');
</script>
</p>
</body>
</html>
--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 20 '05 #2
In message <40********@ola f.komtel.net>, Martin Honnen
<ma*******@yaho o.de> writes
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.writ e. I don't want this output. Any ideas how I can get rid
it?
I am not sure you need that as you could take the script from the src
and rewrite it as necessary


The problem is that I want the values assigned to the variables at the
remote location
but if needed you can disable document.write temporarily to a function
doing nothing and then restore it later:
Great - this is just what I wanted. I thought that there must be some
way of doing it. Many thanks.

<html>
<head>
<title>disabli ng document.write</title>
<script type="text/javascript">
function disableDocWrite () {
document.oldDoc umentWrite = document.write;
document.write = function () {};
}
function enableDocumentW rite () {
document.write = document.oldDoc umentWrite;
}
disableDocWrit e();
</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);
enableDocument Write();
</script>
</head>
<body>
<h1>document.w rite test</h1>
<p>
<script type="text/javascript">
document.write ('Kibology for all.');
</script>
</p>
</body>
</html>


Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
12057
by: Mark | last post by:
Sorry, I'm a newbie to php ;) I was thinking about using php to write the script file, something like: <script type="text/javascript" src="http://insert_url_here.com/myScript.php"></script> The php file then echo'ing the source code. If that works then how can I stop the php file being loaded directly, that is the user browsing
9
2755
by: sergio | last post by:
Hi all, I have created the following script that will show/hide a menu based on checkboxes. It works fine in Opera but not on IE6! Does anybody knows a workaround this problem? Thanks for your response. Sergio ------------------------------------------------ <script language="JavaScript" type="text/javascript">
19
6872
by: dmiller23462 | last post by:
Hi guys....I have absolutely NO IDEA what I'm doing with Javascript but my end result is I need two text boxes to stay hidden until a particular option is selected....I've cobbled together the JavaScript in this code from a couple different sites but I'm not 100% sure what each line is doing...This is the ASP code that I'm using for the page....Take a look at the JavaScript code and please let me know what each line is doing....I have been...
14
4112
by: Eli | last post by:
I've got a script that I'm trying to debug which uses document.write() to place HTML within a page. In both IE6 and Firefox when I view source, I see only the script itself and not any HTML as it's being written into the page. Is there a way that I can view what is being placed into the page, instead of, or in addition to the javascript code?
12
3328
by: Radek Maciaszek | last post by:
Hi It's very interesting problem. I couldn't even find any inforamtion about it on the google. I think that the best way of explain will be this simple example: <html> <body> <script language="JavaScript" type="text/javascript" src="write.js"></script>
8
6614
by: geoffdude | last post by:
Hi everyone, newbie here. I'm really close to finishing my zip code search filter thingy to return a specific message (ultimately a unique phone number for sales contact) after a form query (of sorts) submission. I can get a unique result, but I want that result to write into a specific <div> tag. I can now get the unique result to write into the <div> tag area, but the resulting content immediately disappears, and the original <div>...
11
7831
by: dusk | last post by:
Hi, I'm very new to javascript, and I'm having trouble finding a way to display a string of divs without the code getting really messy. I have several different pages to write, each with about 15-20 divs, and I need users to be able to select a sequence of divs - basically like a series of yes/no questions that, when "yes" or "no" is selected, displays the appropriate div as well as what's come before it. I can hide all divs and display...
1
4280
by: ll | last post by:
I'm currently working on a form which consists of a show and hide javascript. The toggle works fine, although when I click on submit, I would like the page to reload with the toggle (show/hide) div in the same state it was before being submitted. E.G. If the div was visible, I'd like for it to be visible upon return. Here's the script I'm currently using - thanks for any help, Louis --------------------------------------------
7
8962
by: sj071 | last post by:
I'm little more than a novice when it comes to javascript, and this particular problem has been driving me mad for the past few days... The Problem: I have a javascript file that uses document.write to send output to the browser. This javascript file contains some html code and another script tag. The execution order in Internet Explorer (6&7) appears to be different than that of browsers such as FireFox. Example:
0
8466
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8384
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8901
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8813
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8591
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8659
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6212
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5683
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
1791
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.