473,800 Members | 2,476 Online
Bytes | Software Development & Data Engineering Community
+ 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 1769
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
5200
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 calculate the totals in each row. when i try however, i receive the error: "Error: 'elements' is null or not an object"
3
5301
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: http://www.tonh.net/gggallery Vrij Kunst Centrum : http://www.meesterschap.nu
3
2309
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 the anchor text does not contain the "@" symbol, clicking on the link works in a normal fashion. However, if the anchor text is something like "foo@test", then clicking on the text displays the full URL (still goes to the correct link, but I...
9
8803
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 extends to the image. Without the DOCTYPE, the underline appears only for the text. Is there a way to specify a style that I can use with the DOCTYPE that will allow the underline for text in a link but suppress the underline for an image in...
2
2091
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 are taken to the more detail page I have a link to take you back to the list. This all works fine and is standard stuff. My problem is that the user wants the go back link on the detail page to
4
5038
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 name="#FLASH">Flash ...</a></td> It presents the data in the middle of index in an Inline frame. It works real well, looks good, but everytime the link is clicked, the
8
2844
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 when hover over it, can only do so link (text) gets bg color, not entire div.. which of course is no good b/c it only highlights text, not block..
0
1062
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 box then the asp:requiredfieldvalidator message lights up as expected and prevents post back. This works as expected. However, I also have an anchor link on the pages such as <a href="#" onclick = "MyPostBackJavaScript" /> When this link is...
5
3202
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> Now on page2.php I have that anchor placed inside a header tag. The syntax is: <h2><a name="anchor">Header</a></h2> The link on page1.php to the anchor on page2.php works just find in IE7. But it doesn't work in firefox. The link takes the...
0
10504
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10274
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10251
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9085
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7576
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6811
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4149
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3764
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2945
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.