Reply
JS DOM error-thingy
Old 06-04-2006, 11:57 PM JS DOM error-thingy
Moldarin's Avatar
Extreme Talker

Latest Blog Post:
Keyword Density and Title Tags
Posts: 200
Hi,

Ig got myself a little problem here. I am all new to JavaScripting and the whole related DOM-thingy so please bare with me.

Why do not this work!?

Code:
<script type="text/javascript">
   <![CDATA[
      var insertelement = document.getElementById('insertemailhere')
      insertelement.appendChild(document.createTextNode('E-post: '))
      var ns = 'http://www.w3.org/1999/xhtml'
      var emaillink = document.createElementNS(ns,'a')
      emaillink.setAttributeNS (ns,'href','mailto:kontaktATLASchristianknappskog.com?subject=Kontakt%20fra%20christianknappskog.com')
      emaillink.setAttributeNS(ns,'title','Ta kontakt!')
      emaillink.appendChild(document.createTextNode('kontaktATLASchristianknappskog.com'))
      insertelement.appendChild(emaillink)
   ]]>
</script>
<p id="insertemailhere"></p>
To be used in an XHTML document (application/xhtml+xml).
__________________
I do not share ad revenue.
Moldarin is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
     
Old 06-05-2006, 04:09 AM Re: JS DOM error-thingy
chrishirst's Avatar
Super Moderator

Posts: 12,817
Location: Blackpool. UK
define, "doesn't work". as in what does it or not do

you are missing the @ symbol in the email adresses though.
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
Indifference will be the downfall of mankind, but who cares?
Code Samples | People Counting System
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 06-05-2006, 04:15 AM Re: JS DOM error-thingy
Moldarin's Avatar
Extreme Talker

Latest Blog Post:
Keyword Density and Title Tags
Posts: 200
don't work = I do not know what is causing it to not write the output.
__________________
I do not share ad revenue.
Moldarin is offline
Reply With Quote
View Public Profile
 
Old 06-05-2006, 04:55 AM Re: JS DOM error-thingy
chrishirst's Avatar
Super Moderator

Posts: 12,817
Location: Blackpool. UK
How are you debugging it. I would suggest using the javascript console in FireFox

1/ How are you calling the script, If it runs before the <p> is created it will fail

2/ the "<![CDATA" will cause an error if it is in a XHTML document rather than an XML document that is being transformed with XSLT.

works ok for me, once the above points are rectified BTW
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
Indifference will be the downfall of mankind, but who cares?
Code Samples | People Counting System
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Reply     « Reply to JS DOM error-thingy
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.12128 seconds with 13 queries