31 users online (0 members and 31 guests)  


  Results 1 to 6 of 6

Related

  1. scroll images using java script    Forum: Javascript Forum
    Replies: 25
  2. Drop down menus with java script    Forum: Javascript Forum
    Replies: 2
  3. java scroll bar script?    Forum: Website Scripts Forum
    Replies: 1
  4. Another Java-Script Question    Forum: Javascript Forum
    Replies: 4
  5. Other scripts Dhtml / java script    Forum: Javascript Forum
    Replies: 13
  1. #1
    xdeadd0llx's Avatar
    Junior Member

    Status
    Offline
    Join Date
    Nov 2003
    Location
    Adelaide, Australia
    Posts
    25

    Java email script & W3C.org

    Hi folks,

    I need some help rewriting the javascript below in order to make it pass through w3c.org as valid coding. It's a simple enough email "protector".

    Code:
    <script language="JavaScript" type="text/javascript">
    //variables
      var user = "username"; 
      var domain = "domain.com"; 
      var subject = "your subject"; 
      var bodytext = "Body text";
      
      //output
      document.write('<a class="contact" href=\"mailto:' + user + '@' + domain + '?subject=' + subject + '&body=' + bodytext + '\">'); 
      document.write('LinkText</a>');
    </script>
    The w3c.org pics up on the </a> tag within the final document.write specification, saying that the tag wasn't open to begin with. I've tried putting the entire link, including linktext and </a> all in one document.write and still the same thing. If someone who knows a lot more about java than me could rewrite it or offer suggestions, I'd really appreciate it. Thankyou very much.

  2. #2
    Android's Avatar

    Status
    Offline
    Join Date
    Oct 2002
    Location
    I AM CANADIAN
    Posts
    440

    I'm no Java guru but.....

    I think that it's invalid because you're using two 'document.write' 's. That is, it's considering the two statements as separate markup.
    What would happen if you combined them like:
    Code:
    document.write('<a class="contact" href=\"mailto:' + user + '@' + domain + '?subject=' + subject + '&body=' + bodytext + '\">LinkText</a>');
    and make the whole anchor markup in one document.write statement?

  3. #3
    Enigma's Avatar
    Senior Member

    Status
    Offline
    Join Date
    Nov 2000
    Posts
    426
    Quote Originally Posted by xdeadd0llx
    I've tried putting the entire link, including linktext and </a> all in one document.write and still the same thing. If someone who knows a lot more about java than me could rewrite it or offer suggestions, I'd really appreciate it. Thankyou very much.

  4. #4
    Android's Avatar

    Status
    Offline
    Join Date
    Oct 2002
    Location
    I AM CANADIAN
    Posts
    440
    OOPS.....missed that.
    I think that I remember something about a \ that has to go in front of the / in </a> like <\/a>.
    Something like that....... I could be way off, though.

  5. #5
    QuietDean's Avatar
    Administrator

    Status
    Offline
    Join Date
    Oct 2000
    Location
    Bournemouth, UK
    Posts
    2,662
    Androids right -

    http://www.htmlhelp.com/tools/validator/problems.html#script
    If one of our members helps you, please click the icon to add to their reputation!
    No support via email or private message - use the forums!
    Before you ask, have you Searched?

  6. #6
    xdeadd0llx's Avatar
    Junior Member

    Status
    Offline
    Join Date
    Nov 2003
    Location
    Adelaide, Australia
    Posts
    25
    Worked a treat! Thanks guys



Tags for this Thread