SitePoint Sponsor |
|
User Tag List
Results 1 to 5 of 5
Thread: getting the href bit of an <a>
-
Aug 27, 2003, 19:30 #1
- Join Date
- Dec 2002
- Location
- Australia
- Posts
- 221
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
getting the href bit of an <a>
I am not really that good with javascript, but is there a way by javascript to get the href location of and <a>?
I am trying to write a javascript function that is able to read a html document, detects if there are links, and if there are, open them in a new windows.Signature not found.
-
Aug 27, 2003, 22:06 #2
maybe if javascript has a real expression parser
Free Science Homework Help
http://www.physicsforums.com
-
Aug 28, 2003, 05:35 #3
- Join Date
- Feb 2000
- Location
- where the World once stood
- Posts
- 700
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Hi,
This works for me:Code:<a href="<a href='http://members.aol.com/grassblad">GrassBlade</a> <script language="javascript"> alert(document.links[0].href) </script>
If you want to get all of the links within a page, you simply step through the array:Code:for (var i = 0; i < document.links.length; i++) alert(document.links[i].href)
Last edited by Vincent Puglia; Aug 29, 2003 at 05:13.
Where the World Once Stood
the blades of grass
cut me still
-
Aug 28, 2003, 17:14 #4
- Join Date
- Dec 2002
- Location
- Australia
- Posts
- 221
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
thanks to both of u, I'll give it a go
Signature not found.
-
Aug 29, 2003, 05:16 #5
- Join Date
- Feb 2000
- Location
- where the World once stood
- Posts
- 700
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Hi,
if there are links, and if there are, open them in a new windows.
VinnyWhere the World Once Stood
the blades of grass
cut me still
Bookmarks