471,893 Members | 1,984 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

[Greasemonkey] Getting value between tags

3
What I got:
[HTML]<font color="#ffffcc" face="Tahoma, Arial, Helvetica" size="+1">testA</font>
<font color="#ffffcc" face="Tahoma, Arial, Helvetica" size="+1">test1</font>
[/HTML]

What I want:
[HTML]<font color="#ffffcc" face="Tahoma, Arial, Helvetica" size="+1">testA <a href="http://loginpage.php?login=testA">login</a></font>
<font color="#ffffcc" face="Tahoma, Arial, Helvetica" size="+1">test1<a href="http://loginpage.php?login=test1">login</a></font>
[/HTML]
Now I know how to insert the <a> tag but I can't get the "testA", "test1" values. Any help would be greatly appreciated .
Sep 6 '08 #1
5 2829
Dormilich
8,658 Expert Mod 8TB
first, drop the <font> tags, they're deprecated since you can do styling with css.

if you have say
[HTML]<span>test1</span>[/HTML]
you can use
Expand|Select|Wrap|Line Numbers
  1. {span}.firstChild.nodeValue
  2. {span}.value
  3. {span}.innerHTML
there are several ways to get the desired span object...

regards
Sep 6 '08 #2
morbo
3
first, drop the <font> tags, they're deprecated since you can do styling with css.

if you have say
[HTML]<span>test1</span>[/HTML]
you can use
Expand|Select|Wrap|Line Numbers
  1. {span}.firstChild.nodeValue
  2. {span}.value
  3. {span}.innerHTML
there are several ways to get the desired span object...

regards
I have no acces to the page, that is why I need grease monkey
Sep 6 '08 #3
Dormilich
8,658 Expert Mod 8TB
I have no acces to the page, that is why I need grease monkey
this will result in quite a bit of work. the main problem you have (without access to the page) is to address the right font tags. you probably have to get all font tags, check if they contain a link and then you can read the text.

maybe you can provide a link, so I can have a look at the html (this could make things easier).

regards
Sep 6 '08 #4
morbo
3
http://www.hswn.dk/hobbit/servers/servers.html


What I am trying to accomplish is to have an icon next to the server names that connects to a login page and gives the server name as get variable.

ps: the span element is not in my version (runs on secure local network)
Sep 6 '08 #5
Dormilich
8,658 Expert Mod 8TB
nasty bit of tree walking there....

ok, first you need the right table
Expand|Select|Wrap|Line Numbers
  1. var tbl = document.getElementsByTagName("table")[2]; // 3rd table
then select the table rows
Expand|Select|Wrap|Line Numbers
  1. var rows = tbl.childNodes; // tbl.firstChild.childNodes for IE
now get the font tags (loop through the rows) and the text
Expand|Select|Wrap|Line Numbers
  1. var text = rows[i].firstChild.getElementsByTagName("font")[0].firstChild.nodeValue;
I didn't test it, but I think it should work this way.

regards
Sep 6 '08 #6

Post your reply

Sign in to post your reply or Sign up for a free account.

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.