473,326 Members | 2,012 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,326 software developers and data experts.

Obtaining the last inserted node.

Daz
Hi.

I would like to know how to obtain a reference to (or at least, element
type of) the last node which was inserted into the document. I am using
an event listener to listen for dom inserts, but I am not sure how to
check if that last node was a script tag.

Please could someone point me in the right direction?

Many thanks, and Merry Christmas.

Daz.

Dec 25 '06 #1
2 2935
Daz wrote:
I would like to know how to obtain a reference to (or at least, element
type of) the last node which was inserted into the document. I am using
an event listener to listen for dom inserts, but I am not sure how to
check if that last node was a script tag.
If that is the W3C DOM Level 2 DOMNodeInserted event e.g.

document.addEventListener('DOMNodeInserted', function (evt) {
alert(evt.target + ' inserted under parent ' + evt.relatedNode);
}, false);

then the evt.target tells you the inserted node and evt.relatedNode the
parent node into which evt.target has been inserted. So you can check
whether evt.target is an element node and if so, its
tagName.toLowerCase() is 'script'.
--

Martin Honnen
http://JavaScript.FAQTs.com/
Dec 25 '06 #2
Daz

Martin Honnen wrote:
Daz wrote:
I would like to know how to obtain a reference to (or at least, element
type of) the last node which was inserted into the document. I am using
an event listener to listen for dom inserts, but I am not sure how to
check if that last node was a script tag.

If that is the W3C DOM Level 2 DOMNodeInserted event e.g.

document.addEventListener('DOMNodeInserted', function (evt) {
alert(evt.target + ' inserted under parent ' + evt.relatedNode);
}, false);

then the evt.target tells you the inserted node and evt.relatedNode the
parent node into which evt.target has been inserted. So you can check
whether evt.target is an element node and if so, its
tagName.toLowerCase() is 'script'.
--

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

Thanks Martin. :)

Dec 25 '06 #3

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

Similar topics

9
by: Roger Withnell | last post by:
I'm inserting a new record into an MS SQL database table and I want to obtain the new records autonumber immediately afterwards, as follows: MadminRS.CursorLocation = adUseServer...
1
by: PT | last post by:
I got a problem. And thats..... First of all, I got these three tables. ------------------- ------------------ ---------------------- tblPerson tblPersonSoftware ...
0
by: Steve Roberts | last post by:
I want to write a graphical view of an XML tree, using a DOM interface, that allows the XML tree to be edited, with nodes being added or removed. For this I was going to create a basic tree...
6
by: JonQuark | last post by:
Hi, I suspect this is a common question but I've read the FAQ and searched the archives and couldn't find it. In a script embedded in the body of the page I want to quickly find the last node...
2
by: chris yoker via DotNetMonster.com | last post by:
hiya, I can obtain innnerText of a node as follows: <code> itemCode = currNode.ChildNodes(4).InnerText() <\code> great, but if change the XML node order, then I have to re-code. I tried...
2
by: Kevin Burton | last post by:
I don't think I understand the last() function. I have a document that looks like: <Root> <Header>Some text</Header> <Message> <MessageID>1</MessageID> . . . . </Message>
16
by: sangram | last post by:
how to delete last node of a Linked list if you only know the address of last node. thanks sangram
7
by: dennis.sprengers | last post by:
I am trying to write an editor object, which adds some functionality and a toolbar to every textarea with a "form-textarea" class. Both FF and IE generate an error in line 20...
7
by: Ebenezer | last post by:
Hello! Let's suppose we have an XML with some nested NODE nodes: <root attr="first"> <node id="1" attr="mike"> <node id="2" /> <node id="3" attr="dave" /> </node> <node id="4">
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.