Hi,
does anyone know of any javascript method that does the same job as
document.write( ), but not necessarily at the end of the document? For
instance, insert some text inside an element that has a specific ID
tag?
thanks a lot
JL 25 3502
jullag wrote on 19 sep 2005 in comp.lang.javas cript: Hi,
does anyone know of any javascript method that does the same job as document.write( ), but not necessarily at the end of the document? For instance, insert some text inside an element that has a specific ID tag? thanks a lot JL
document.write( ) can be used anywhere in a html document, but it should
only be used before the document is fully loaded and an implicit
document.close( ) is issued.
Any next document.write( ) will implicidly do a document.open() , thereby
destroying the whole page inclusive of any onpage javascript.
--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)
jullag wrote: does anyone know of any javascript method that does the same job as document.write( ), but not necessarily at the end of the document? For instance, insert some text inside an element that has a specific ID tag? thanks a lot JL
document.getEle mentById("MyDiv ").innerHTML="w hatever"
--
--.
--=<> Dr. Clue (A.K.A. Ian A. Storms) <>=-- C++,HTML, CSS,Javascript
--=<> http://resume.drclue.net <>=-- AJAX, SOAP, XML, HTTP
--=<> http://www.drclue.net <>=-- SERVLETS,TCP/IP, SQL
--.
Dr Clue wrote: jullag wrote:
does anyone know of any javascript method that does the same job as document.write( ), but not necessarily at the end of the document? For instance, insert some text inside an element that has a specific ID tag? thanks a lot JL
document.getEle mentById("MyDiv ").innerHTML="w hatever"
I'm also having a document.write( ) problem.. document.write is
generated dynamically, and everything else in the page disappears when
document.write( ) executes.. thank you...
Frances
Frances said: Dr Clue wrote: jullag wrote:
does anyone know of any javascript method that does the same job as document.write( ), but not necessarily at the end of the document? For instance, insert some text inside an element that has a specific ID tag? thanks a lot JL
document.getEle mentById("MyDiv ").innerHTML="w hatever"
I'm also having a document.write( ) problem.. document.write is generated dynamically, and everything else in the page disappears when document.write () executes.. thank you...
That's exactly what document.write( ) is supposed to do.
The first call to document.write( ) after the page has been displayed
generates a call to document.open() , to re-open it for writing.
document.open() , in turn, always calls document.clear( );
jullag wrote: Hi,
does anyone know of any javascript method that does the same job as document.write( ), but not necessarily at the end of the document? For instance, insert some text inside an element that has a specific ID tag? thanks a lot JL
Hi JL,
Off the top of my head, I can think of 2 ways.
Suppose you had an element:
<div id = "mydiv"></div>
and you wanted to insert text in between the div tag. You can do the
following:
var div = document.getEle mentById("mydiv ");
var text = document.create TextNode("my text");
div.appendChild (text);
OR
document.getEle mentById("mydiv ").innerHTM L = "my text";
Hope this helps. :)
JRS: In article <43************ *********@news. sunsite.dk>, dated Mon,
19 Sep 2005 13:48:51, seen in news:comp.lang. javascript, Frances
<fd***@yahoo.co m> posted : Dr Clue wrote: jullag wrote:
does anyone know of any javascript method that does the same job as document.write( ), but not necessarily at the end of the document? For instance, insert some text inside an element that has a specific ID tag?
document.getEle mentById("MyDiv ").innerHTML="w hatever"
I'm also having a document.write( ) problem.. document.write is generated dynamically, and everything else in the page disappears when document.write () executes.. thank you...
Both respondents, and the OP, should read the newsgroup FAQ.
To be clueful, recommendation of getElementByID should be accompanied by
noting that it does not work on all browsers (see FAQ) and that it can
be emulated well enough for some of the others.
if (document.all && !document.getEl ementById) {
document.getEle mentById = function(id) { return document.all[id] } }
--
© John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 IE 4 ©
<URL:http://www.jibbering.c om/faq/> JL/RC: FAQ of news:comp.lang. javascript
<URL:http://www.merlyn.demo n.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demo n.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Dr John Stockton said the following on 9/19/2005 4:20 PM: JRS: In article <43************ *********@news. sunsite.dk>, dated Mon, 19 Sep 2005 13:48:51, seen in news:comp.lang. javascript, Frances <fd***@yahoo.co m> posted :
Dr Clue wrote:
jullag wrote:
does anyone know of any javascript method that does the same job as document.wr ite(), but not necessarily at the end of the document? For instance, insert some text inside an element that has a specific ID tag? document.get ElementById("My Div").innerHTML ="whatever"
I'm also having a document.write( ) problem.. document.write is generated dynamically, and everything else in the page disappears when document.writ e() executes.. thank you...
Both respondents, and the OP, should read the newsgroup FAQ.
To be clueful, recommendation of getElementByID should be accompanied by noting that it does not work on all browsers (see FAQ) and that it can be emulated well enough for some of the others.
if (document.all && !document.getEl ementById) { document.getEle mentById = function(id) { return document.all[id] } }
And that it is only needed for a browser that is almost 10 years old?
--
Randy
comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
jullag wrote: Hi,
does anyone know of any javascript method that does the same job as document.write( ), but not necessarily at the end of the document? For instance, insert some text inside an element that has a specific ID tag? thanks a lot JL
It is interesting that document.write is taboo in xhtml 1.1 served
correctly as application/xhtml+xml. Most of the recent browsers can
handle this mime type, but not the badly outmoded IE6(you can use a php
include at the very top of the page to automatically rewrite the code
as html 4.01 strict if you run into an outmoded browser). When you
write in xhtml 1.1 and serve as the correct mentioned mime type, modern
browsers including Opera and the Mozilla family(Mozilla, Firefox,
Netscape) become extremely strict and parse the code as xml. One reason
a document.write can not be allowed, is there is no telling what it
might write including tags that are not closed or xml forbidden
characters. Thus document.write can not be allowed. If you use
document.write, even in an external script, the page will not display
and you may get a xml parse error message from the browser. I often use
server-side php script to get around this problem. For example, my
60000 year perpetual calendar needs hundreds of divisions to write a
calendar for a full year. This was done with javascript using a
document.write at the bottom of a nest of 4 "for" loops to write all of
the divisions. This all had to go on conversion to xhtml 1.1 served
with the proper mime type. One enters the desired year, which is sent
to the server. Then the server uses php to write the code for the
calendar for the selected year, which produces hundreds of divisions.
This code is then downloaded to the browser, and the xml parser is
pleased because it can check all of the computed divisions for closing
tags, xml forbidden characters, and such. Many are kicking and
screaming about using true xhtml, but it can be done now in most cases
with automatic conversion to html 4.01 strict for outmoded browsers. If
one only considered PCs, there might be little justification for xhtml
and xml purity. However there are now a large number of computing
devices out there in addition to PCs. To allow the many devices to
exchange information, they all need to conform to xml or some other
standard they they all can understand. For now, xml seems to be the
best common language for most devices that we have.
JRS: In article <49************ ********@comcas t.com>, dated Mon, 19 Sep
2005 18:58:42, seen in news:comp.lang. javascript, Randy Webb
<Hi************ @aol.com> posted : Dr John Stockton said the following on 9/19/2005 4:20 PM:
To be clueful, recommendation of getElementByID should be accompanied by noting that it does not work on all browsers (see FAQ) and that it can be emulated well enough for some of the others.
if (document.all && !document.getEl ementById) { document.getEle mentById = function(id) { return document.all[id] } }
And that it is only needed for a browser that is almost 10 years old?
You exaggerate : the system age is less than three-quarters of that.
Not everyone uses the latest systems (vulnerable to the latest malware).
Indeed, you yourself are using, AIUI, an out-of-date newsreader.
<QUOTE>
Can
User-Agent: Mozilla Thunderbird 0.7.2 (Windows/20040707) X-Accept-Language: en-us, en
be set to properly unambiguous date-stamps, rather than such as
9/1/2005 6:13 PM meaning Sep 1st
and, if so, how?
I don't think it's alterable, but there have been several upgrades
since then. Version 1.0.2 gives the proper dd mmm yyyy hh:mm:ss format.
</QUOTE>
Of course, even that format is not as proper as it would be if it
followed ISO 8601.
--
© John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 MIME. ©
Web <URL:http://www.merlyn.demo n.co.uk/> - w. FAQish topics, links, acronyms
PAS EXE etc : <URL:http://www.merlyn.demo n.co.uk/programs/> - see 00index.htm
Dates - miscdate.htm moredate.htm js-dates.htm pas-time.htm critdate.htm etc. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: techy techno |
last post by:
Hii
Just wanted to know how can I decorate my texboxes and Listmenu which is
called from a JS file using the following code below:
document.write("<SELECT NAME='cur2' ONCHANGE='cconv1();'>");
document.write("<OPTION VALUE='0.345066110642241'>Argentina Peso
</OPTION>");
document.write("<OPTION VALUE='0.790200069503053'>Australia Dollar
|
by: Catherine Lynn Smith |
last post by:
I am creating a webpage with dhtml <DIV> layers and I want a link on
one layer to modify the content on another but I seem to keep running
into errors.
Basically I create a layer in the middle of the screen that initially
comes up with a gif image of a house:
<!-- start "house" layer definition for center of screen -->
<DIV id="house" style="position:absolute; left:140px; top:137px;
width:510px; height:325px; z-index:2"><img...
|
by: Brett Baisley |
last post by:
Hello
I have a block of html code that I want to run by calling a javascript
function to print it. Its basically a table with menu items in it that is
the same for many pages, and instead of copying/pasting everytime I change
it, I figure this will be better, as I only change it once.
The problem is, document.write doesn't handle multiple lines very well, so I
was wondering what is the best way to do this? Maybe there is even a better...
|
by: Rithish |
last post by:
I want to emulate paging in an HTML document. something like,
-------------------------
| |
| <DIV> |
| |
| <TABLE></TABLE> |
| |
| <TABLE></TABLE> |
| |
|
by: Charles Crume |
last post by:
Hello all;
I have a web page that displays a blank gif for about 2 seconds, then
displays an animated gif image, then, after the animation plays, I want to
display a link so the user can click on it and go to another page. I am
fairly new to javascript and came up with the following code:
-----------------------
<p align="center"><img src="images/nil.gif" align="middle" width="375"
height="300" name="blank_image"></p>
| |
by: PHP2 |
last post by:
how I can create frame inside in total middle of document with?
I have one htnl and I need html page totaly in middle..
|
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>
|
by: SuneR |
last post by:
Hi,
I am having problems figuring out how to make Firefox behave, and
output the HTML I want it to output.
The thing I want done is actually quite simple. I have a <labeltag,
and inside it, I have a script tag, that document.write's some HTML.
Like this:
|
by: ankit1999 |
last post by:
I have a problem,
everytime i'm run this page
http://click2travel.in/index.php
i get the this error,,,
|
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,...
|
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...
| |
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...
|
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...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
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...
| |