Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating a Hyperlink Node

Status
Not open for further replies.

b00ger

Programmer
Oct 22, 2003
7
US
I'm trying to create a hyperlink node and append it as a child to a table cell. I've sucessfully appended a text node to the table cell using document.createTextNode() and appending it using the myCell.appendChild(myTextNode), but I cannot figure out how to put a hyperlink there. Any help would be greatly appreciated. Thanks!
 
newLink = document.createElement("a")
newLink.href = "somePage.htm"
newLink.target = "_blank"
myCell.appendChild(newLink)

Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook (No, I'm not Rick)

fart.gif
 
mwolf00, thanks for your reply. do you know the attribute to assign the text to the link, that is, what you click on when viewing the link on the page. do you append a text node to it? thanks again!
 
Unfortunately, you would need to append a text node as a child. That is the very reason the I use .innerHTML in this instance. Nodes are a little bothersome when you want to label inputs and links...

Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook (No, I'm not Rick)

fart.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top