473,770 Members | 2,126 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

document.write( ) in the middle of a document?

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

Sep 19 '05
25 3506

Frances wrote:
web.dev wrote:
Frances wrote:
Frances wrote:

Frances wrote:
>km0ti0n wrote:
>
>
>>I fyou are getting ("document.getE lementById("") is null or not an
>>object.. ") errors make sure you are referenceing the element correctly.
>> By checking the ID of the element is correct and make sure the the
>>elements id isn't duplicated.
>>
>>I see you have this
>>
>>document.g etElementById(" divPricing").ap pendChild( iframe );
>>
>>You should have the corrisponding HTML :
>>
>><div id="divPricing" > .... </div>
>>
>>Normally it's a typo....
>>
>>Also you are *STILL* using selItem =
>>list.optio ns[list.selectedIn dex].value; and not just list.value. they
>>are the same.
>
>
>
>ok, am trying a different approach, iframes print w/a border that I
>can't get rid of.. not sure yet whether will go w/iframes or not, but
>at any rate am having problems w/this approach also:
>
> in <body>:
><option value="val1">Pr oduct One</option>
><option value="val2">Pr oduct Two</option>
><option value="val3">Pr oduct Three</option>
><option value="val4">Pr oduct Four</option>
>
>in <head>:
>function pricing() {
>var val1 = "Product One";
>var val2 = "Product Two";
>var val3 = "Product Three";
>var val4 = "Product Four";
>
> var list = document.forms[0].product;
> var selItem = list.value;
>var copy = "" + selItem + "";
>var div = document.getEle mentById("divPr icing");
>var divCopy = document.create TextNode(copy);
>
> div.appendChild (divCopy); // prints, for example,
> // (no quotes) 'val4' instead of 'Product Four'...
>
>// div.innerHTML = divCopy; // this prints '[object]' (no quotes)
> }
>
>
>again many thanks for your help...... Frances

ok, I think I need to go back to iframes..

the problem is a very odd one.. pls see below:

function pricing() {
var list = document.forms[0].product;
var selItem = list.value;
var ifr = document.create Element("iframe ");
//ifr.src = "iframes/' + selItem + '.html"; // *** get a 404..

look @ 2 following lines.. this is very weird..
ifr.src = "iframes/' + 'aa' + '.html"; // **** get a 404..

ok, above line is wrong (the quotes..)
however when did this still got 404..

ifr.src = '"iframes/' + 'aa' + '.html"';

I don't see why you even need to place in double quotes. The whole
thing is a string value. The above code statement is equivalent to the
following:

ifr.src = '"iframes/aa.html"';


ok, what confused me is that in TAG (<iframe>) you have to put (I think)
attr under src in quotes (<iframe src="file.html" ..>) is this right? at
any rate not sure this is 100% required so left them out.. but of course
you're right, I'm not even generating iframe w/a conventional tag so I
guess that requirement doesn't apply..

finally got this to work thus:

list = document.forms[0].product;
selItem = list.value;
var ifr = document.create Element("iframe ");
ifr.src = 'iframes/' + selItem + '.html';
ifr.scrolling = 'no';
ifr.style.borde rWidth='0'; // this only stuff that's not working..


It is working. But it's probably not the border you were thinking of.
That border is for placing a border around the entire iframe. And if
that's the case, then you still have what you asked for, a zero border.
But if you wanted something visible, you might also want to set the
borderStyle and the borderColor.
document.getEle mentById("divPr icing").appendC hild(ifr);
problem NOW is that when user goes back to sel obj and selects a diff.
product new iframe gets placed BESIDE current one, not in same place
where other one is :( (which is weird b/c iframe is inside a div
positioned absolutely w/css.. I guess have to do the visible/hidden
thingie w/css...)

again, many thanks for your help..... Frances


Hiding the other frames with css is not a good solution. Consider
this, what if the user continuously selects a different product? Then
the page will continue to append a new child.

What you'll have to do is use the replaceChild method.

document.getEle mentById("id"). appendChild(new Child, oldChild);

Sep 21 '05 #21
km0ti0n wrote:
First thing i notice is the way you are referencing the
value of the select please read this :

http://km0ti0n.blunted.co.uk/viewfaq...29154586250000


The value property of an HTMLSelectEleme nt is specified in the W3C HTML
DOM standard, and is a formalisation of pre-existing behaviour from some
browser implementations . It was not universal at the time of its
standardisation and so its use in place of looking up the value of a
selected option with the selectedIndex property will needlessly
sacrifice browser compatibility. This would not be wise in a script such
as a form validation script that does not itself have a dependency on
other more recent DOM features.

Richard.
Sep 22 '05 #22
Frances wrote:
<snip>
var copy =+ '</iframe>'; // ******** prints 'NaN'

<snip>

The compound assignment and concatenation operator is +=, you have
written =+, which is assignment and unary plus. Unary plus type-converts
its string operand - "</iframe>" - into the number NaN, and then the
assignment replaces the value of - copy - with that NaN value.

Richard.
Sep 22 '05 #23
Dr John Stockton said the following on 9/20/2005 4:04 PM:
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.


I said nothing about system age, I said the browser is almost 10 years old.

And considering that IE4.0 was released in October of 1997, that makes
the browser a tad under 8 years old. And in the age of the Web, that is
ancient.
Not everyone uses the latest systems (vulnerable to the latest malware).
Not all latest systems are vulnerable to that malware. It only takes a
little common sense and understanding of your computer to keep it free
of malware.
Indeed, you yourself are using, AIUI, an out-of-date newsreader.
Oh well.
<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.


If it did, I would change it back to the way I have this one set as it
is in the format I prefer. The only people that seem to have a problem
with my date format are people who have nothing better to whine about
than a date format. And anybody who confuses the date of 9/1/2005 with
1/9/2005 in Usenet context doesn't need a Newsreader, they need a head
shrink.
</QUOTE>

Of course, even that format is not as proper as it would be if it
followed ISO 8601.

--
Randy
comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
Sep 22 '05 #24
Richard Cornford wrote:
km0ti0n wrote:
First thing i notice is the way you are referencing the
value of the select please read this :

http://km0ti0n.blunted.co.uk/viewfaq...29154586250000

The value property of an HTMLSelectEleme nt is specified in the W3C HTML
DOM standard, and is a formalisation of pre-existing behaviour from some
browser implementations . It was not universal at the time of its
standardisation and so its use in place of looking up the value of a
selected option with the selectedIndex property will needlessly
sacrifice browser compatibility. This would not be wise in a script such
as a form validation script that does not itself have a dependency on
other more recent DOM features.

Richard.


yes, I tried this, it works.. thank you.. I like it, simpler than other
way... (also thanks for pointing out I had wrong var decl (=+ instead
of +=..)
Sep 22 '05 #25
web.dev wrote:
Frances wrote:

document.getEle mentById("divPr icing").appendC hild(ifr);
problem NOW is that when user goes back to sel obj and selects a diff.
product new iframe gets placed BESIDE current one, not in same place
where other one is :( (which is weird b/c iframe is inside a div
positioned absolutely w/css.. I guess have to do the visible/hidden
thingie w/css...)

again, many thanks for your help..... Frances

Hiding the other frames with css is not a good solution. Consider
this, what if the user continuously selects a different product? Then
the page will continue to append a new child.

What you'll have to do is use the replaceChild method.

document.getEle mentById("id"). appendChild(new Child, oldChild);


thank you very much for yr help.... so in order for this to work I have
to put a blank iframe there initially so I can replace it afterwards..
this is how I figured, but unfortunately having some problems...

var selItem;
var ifrCurr;
var div = document.getEle mentById("divPr icing");
// this var not being read inside functions..
// (even if I take out 'var' from declaration..)

function currIF() { // to put a blank iframe..
ifrCurr = document.create Element("iframe ");
ifrCurr.src = 'iframes/blank.html';
//div.appendChild (ifrCurr); // ****** var not being read...

document.getEle mentById("divPr icing").appendC hild(ifrCurr);
// errror on this line
// is null or not an obj... (??)
// no problem w/this line in below function..
}
window.onload=c urrIF();

function pricing() {
selItem = document.getEle mentById("produ ct").value;
var ifr = document.create Element("iframe ");
ifr.src = 'iframes/' + selItem + '.html';
ifr.scrolling = 'no';
ifr.style.borde rWidth='0';
ifr.setAttribut e(selItem, name);
document.getEle mentById("divPr icing").appendC hild(ifr);
// div.appendChild (ifr); // ******* var not being read...

// document.getEle mentById("divPr icing").replace Child(ifr,ifrCu rr);
// can't use this line yet b/c problems w/function above....
}

thank you very much........ Frances
Sep 22 '05 #26

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

Similar topics

1
2873
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
3
9843
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...
2
2386
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...
10
13680
by: Rithish | last post by:
I want to emulate paging in an HTML document. something like, ------------------------- | | | <DIV> | | | | <TABLE></TABLE> | | | | <TABLE></TABLE> | | |
4
2983
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>
4
1441
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..
12
3347
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>
5
2970
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:
5
4014
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,,,
0
9618
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
10101
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
10038
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
8933
agi2029
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...
1
7456
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
5354
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...
0
5482
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4007
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2850
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.