473,490 Members | 2,737 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

appendChild not attaching anchor link as expected

65 New Member
I have a simple XMLHttpRequest that grabs a list of messages from my server (I posted a question for a different aspect of this earlier)

I have decided to improve on it a little by adding in things that my message logger does (server-side) to turn things like:
Expand|Select|Wrap|Line Numbers
  1. http://www.example.com
or:
Expand|Select|Wrap|Line Numbers
  1. http://example.com
into URLs automatically by slapping on
Expand|Select|Wrap|Line Numbers
  1. <a href="http://www.example.com" target="_blank">www.example.com</a>
when:
Expand|Select|Wrap|Line Numbers
  1. www.example.com
is found in a message.

I checked and double-checked the message log, and it is properly parsing the text to include valid HTML. The problem occurs when I receive the text on the client. It iterates through all the child elements of the <content> element of each <message> element, and appends them to a <span> element inside a <p> element that it will be appended to the chat history. It seems to be properly attaching the <a> element including the text inside, but it is not clickable, as if I passed it without the href attribute. Anyone have any insight to this?

Library file: http://preview.moltx.name/chat_v2/library.js

EDIT: The place in which I am attaching all the elements of the message occur between lines 264 and 274.

If you wish to test the script, just enter a username, and create a room, then enter any URL into the script at:
http://preview.moltx.name/chat_v2/

Also, inspecting the elements using Firebug in Firefox reveals that the href is there, but unless I delete and re-add the element manually, it does not act like a link completely (but it stands out like one).
Dec 6 '08 #1
1 1758
pronerd
392 Recognized Expert Contributor
I can not follow the code. It looks like you are iterating over an newly declared empty array. The simplest way to see the problem would probably be to show the innerHTML attribute from the created element in an alert call so you can see the actually HTML that is being created.


Expand|Select|Wrap|Line Numbers
  1.  
  2.     var genHTML = message.innerHTML;
  3.     alert('  HTML CREATED : '+genHTML);
  4.  
  5.  
Dec 6 '08 #2

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

Similar topics

25
5128
by: kie | last post by:
hello, i have a table that creates and deletes rows dynamically using createElement, appendChild, removeChild. when i have added the required amount of rows and input my data, i would like to...
3
5292
by: Ton den Hartog | last post by:
What is the difference between a link and an anchor in Javascript (DOM level 0) ? Ton -- Computer museum tonh: http://www.tonh.net/museum - 10.000 visitors !! GGGallery website generator:...
3
2286
by: ehm | last post by:
I have encountered an issue that has me totally confused. I have a page where the user clicks on a hyper-text link and is then directed towards another page (passing additional variables, etc.). If...
9
8778
by: David Ross | last post by:
In some cases, I indicate links with both a small image and also text, both in the same anchor. When I upgrade my pages to incluce DOCTYPE for HTML 4.01 transitional, the underline for the link...
2
2076
by: Astra | last post by:
Hi everybody Need your help. I have a DB-extracted list of say 5 items per page, which have links on each one that takes you to more detailed info on the 'clicked' particular item. When you...
4
5026
by: catyionic | last post by:
Greetings: I have numerous links on index.html...example of one..... <A HREF="stage.html#Flash" target="left">Flash</A> It connects to page named stage.html ... which contains... <a...
8
2829
by: maya | last post by:
I have some links.. http://www.francesdelrio.com/linksCSS.html want it so when you hover over link ENTIRE DIV gets gray bg color (not just text (like link Three is now on this page..) but...
0
1041
by: Jerry J | last post by:
I have a text box that is validated using an asp:requiredfieldvalidator. There is an asp button control that posts back to the server. When the button is pressed, if there is no data in the text...
5
3184
by: Meadock | last post by:
Here's an example of what i'm trying to do. At www.webpage.com/page1.php, there's a link that points to an anchor at www.webpage.com/page2.php. The syntax is: <a href="page2.php#anchor">Link</a>...
0
7112
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6974
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7183
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6852
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7356
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
3084
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3074
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
628
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
277
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.