473,383 Members | 1,815 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,383 software developers and data experts.

getting coordinates of a text node (in Firefox)

hi,

is there a way of getting the position and size of a text node in
Firefox without altering the DOM? For example, suppose I have a
document fragment like this:

<div>
textnode1
<img>
textnode2 textnode3
</div>

I can get the div's coordinates, but that doesn't help me much if I
want to know the position (and ideally also the size) of textnode2. I
could wrap the text node into a new <spanelement, but that often
alters the look of the page.

I need this for a xulrunner application, so it's fine if it only works
in (some version of) Firefox/Mozilla.

Thanks,
wo.

Dec 12 '06 #1
2 3228
wo**************@gmail.com wrote:
is there a way of getting the position and size of a text node in
Firefox without altering the DOM? For example, suppose I have a
document fragment like this:

<div>
textnode1
<img>
textnode2 textnode3
</div>
Why would you have two text nodes after the img element? Are you
constructing the DOM with script and appending two text nodes? Otherwise
there is only one text node after the img, even if there are several
words in the text contents.

I need this for a xulrunner application, so it's fine if it only works
in (some version of) Firefox/Mozilla.
I don't know of any properties exposes in Mozilla's DOM on text nodes
that would yield a position. You might want to ask in mozilla.dev.tech.dom.
--

Martin Honnen
http://JavaScript.FAQTs.com/
Dec 12 '06 #2
Thanks Martin,

On Dec 13, 12:41 am, Martin Honnen <mahotr...@yahoo.dewrote:
Why would you have two text nodes after the img element? Are you
constructing the DOM with script and appending two text nodes? Otherwise
there is only one text node after the img, even if there are several
words in the text contents.
I actually need the coordinates of every line of text on the page,
that's why I split the text nodes at linebreaks.

wo.

Dec 13 '06 #3

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

Similar topics

6
by: Ron Brennan | last post by:
I want if possible to use something like: element.getElementsByTagName('text') but that doesn't work. Is there another value for the parameter, or is it not possible with getElementsByTagName?...
3
by: Robert Oschler | last post by:
What's a good way to find a specific text node element in a web page's DOM tree? I thought of traversing each node but there has to be a faster way. Is there a "find text node by nodeValue"...
15
by: Aaron Gray | last post by:
<iframe name="iframe" width="100%" height="25%" src="test1.txt"> </iframe> <a href="test1.txt" target="input">one</a> <a href="test2.txt" target="input">two</a> <form name="form1"> <textarea...
1
by: David | last post by:
All I am using the code below in order to read an XML file in the format: <root> <selection-attr attr="p70"> <value code="Mr">Mr</value> <value code="Mrs">Mrs</value> <value...
1
by: blabla120 | last post by:
Hello, I have a XML file <car> <brand>Mercedes</brand> </car> I want to transform it to this form:
9
by: martymix | last post by:
simple question: I have a simple <dt>test text</dt> I get the innerHTML of that dt, and I try and append some text to it like so: dt = document.getElementsByTagName('dt') var text =...
7
by: Thomas Schmidt | last post by:
Hi all, I need an XPath which selects all nodes of a specific name which start with a text node, i.e. I want the expression to select: <x> abcdefg <y>hijklmn</y> </x>
1
by: jambalapamba | last post by:
Hi I am walking xml using c# and i want add attribute (style="text-decoration: line-through;" ) to the parent node of text node if the value meets some condition. e.g if this...
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.