473,388 Members | 1,234 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

DOM: Inserting text between <head> and <body>

Hi.

I'm trying to insert some text between <head> and <body> but I'm
not able.

I try with:
--------
bodyPoint = document.getElementsByTagName('body');

var myLink = document.createElement("a");
myLink.href = "http://www.yahoo.com";
myLink.innerHTML = "Yahoo";
bodyPoint.insertBefore(myLink, bodyPoint);
---------

but it doesn't work. I get this error
-----------
bodyPoint.insertBefore is not a function
--------------

What am I doing wrong? Thx.

Jul 24 '05 #1
3 2269
fr**********@usa.com wrote:
Hi.

I'm trying to insert some text between <head> and
<body> but I'm not able.
Good, because it makes no sense what so ever to place text between the
HEAD element and the BODY element.
I try with:
--------
bodyPoint = document.getElementsByTagName('body');
A call to the getElementsByTagName method returns an object implementing
the NodeList interface.
var myLink = document.createElement("a");
myLink.href = "http://www.yahoo.com";
myLink.innerHTML = "Yahoo";
bodyPoint.insertBefore(myLink, bodyPoint);
---------

but it doesn't work. I get this error
-----------
bodyPoint.insertBefore is not a function
The NodeList interface does not implement an insertBefore method.
--------------

What am I doing wrong? Thx.


Failing to RTFM, or failing to think about their content.

Richard.
Jul 24 '05 #2
> "fr**********@usa.com" <fr**********@usa.com> wrote:
news:11**********************@f14g2000cwb.googlegr oups.com....

Hi.

I'm trying to insert some text between <head> and <body> but I'm
not able.

I try with:
--------
bodyPoint = document.getElementsByTagName('body');

var myLink = document.createElement("a");
myLink.href = "http://www.yahoo.com";
myLink.innerHTML = "Yahoo";
bodyPoint.insertBefore(myLink, bodyPoint);
---------

but it doesn't work. I get this error
-----------
bodyPoint.insertBefore is not a function
--------------

What am I doing wrong? Thx.


window.onload=function(){
htm = document.getElementsByTagName('html')
myLink = document.createElement("a");
myLink.href = "http://www.yahoo.com";
txt = document.createTextNode('Yahoo')
myLink.appendChild(txt)
htm[0].insertBefore(myLink,document.body);
alert(htm[0].innerHTML)
}
--
BootNic Sunday, July 24, 2005 4:05 PM

Good communication is as stimulating as black coffee and just as hard to sleep after.
*Anne Morrow Lindbergh*

Jul 24 '05 #3
ASM
fr**********@usa.com wrote:
Hi.

I'm trying to insert some text between <head> and <body> but I'm
not able.

I try with:
--------
bodyPoint = document.getElementsByTagName('body');
not correct : you got the body tree (collection of all body tags)
Hu ? there is only one ?
Does browser know you use a collection instruction to catch one object ?

bodyPoint = document.getElementsByTagName('body')[0];
var myLink = document.createElement("a");
myLink.href = "http://www.yahoo.com";
myLink.innerHTML = "Yahoo";
bodyPoint.insertBefore(myLink, bodyPoint);
---------

but it doesn't work. I get this error
-----------
bodyPoint.insertBefore is not a function


because ? bodyPoint is an array

to which one of its elements the browser will address insertion ?

--
Stephane Moriaux et son [moins] vieux Mac
Jul 24 '05 #4

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

Similar topics

1
by: RWC | last post by:
Hey Folks! I'm having trouble with an asp page. First off, I'm new to the html / asp world, but not to software development. I'd like to minimize or "normalize" the site, so I'm trying to use...
6
by: Jon Davis | last post by:
I recently learned how to do an <OBJECT> alternative to <IFRAME> in current browsers using: <object id="extendedhtml" type="text/html" data="otherpage.html" width="250" height="400"></object> ...
23
by: Loony | last post by:
I have got a code like this in HTML section in ASP file which includes javascript file! The script works under MS IE but doesn't with Firefox! Can anybody tell me what is wrong? <HTML>...
10
by: Brian W | last post by:
Hi All, I have a web user control that, among other things, provides Print this page, and Email this page functionality I have this script that is to execute on the click of the asp:hyperlinks ...
0
by: Henri | last post by:
Hi, I've built a custom control named Tree in MyNameSpace.Tree compiled into dans MyNameSpace.Tree.dll I've then designed a page index.asp with its code in index.aspx.vb (class PageIndex)....
3
by: phpmel | last post by:
Hi guys, I have yet another question. I am working with this html form that uses a template. <head> //is greyed out //some greyed out <style >stuff is next <!-- InstanceEndEditable...
3
by: PYG | last post by:
Hi everybody I have a simple question : If i use this code : <body style="font-size:24px;color:blue;"> Text in body <table> <tr><td> Text in table
1
by: bartholomeus | last post by:
Hello all, I would greatly appreciate suggestions on my following PHP4 problem: In PHP5 this works: $employee = $dom->getElementsByTagName('employee')->item(0); In PHP4 this doesn't work:...
2
by: urbanedge | last post by:
I've just acquired a site and uploaded to godaddy and the email function won't work. I'm new to php and I'm not able to determine where the issue is. I've commented out $this->header .=...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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,...
0
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...

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.