Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jan 2007
    Thanked 0 Times in 0 Posts

    Modifying an onclick link

    Hi. :)

    Right now, I am trying to make my site validate with HTML4.01 strict and I was doing a pretty good job until I came across a problem with CuteNews. When you post new news, you can click on a smiley to add it, and it is added with Javascript. The problem with this is, the javascript doesn't add an alt tag to the image. I was messing around with the code, but I am not very familiar with javascript, so I was wondering how I can tell it to add " alt='smilename' " each time. Here is the line of code where it needs to be added (the first part, with the link):

     $output .= "<a href=# onclick=\"document.getElementById('$insert_location').contentWindow.document.execCommand('InsertImage', false, '$config_http_script_dir/data/emoticons/$smile.gif' + 'alt=$smile'); return false;\"><img src=\"$config_http_script_dir/data/emoticons/$smile.gif\" style=\"border: none;\" alt=\"$smile\"></a>";
    (The img tag here, is the image of the smiley within the CuteNews admin panel, that you click to put it into your news post)

    I was messing around with it, trying to get it to work and I added " + 'alt=$smile' " which gives me this when I click it:
    <img src="http://www.geekified.net/blog/data/emoticons/wink.gifalt=wink">
    The alt is being added, but the quotations aren't working and there isn't a space. Like I said, I am not familiar with javascript, so I may be missing something that is fairly simple.

    I hope that all of this makes sense...and thanks in advance. (:

  • #2
    New Coder TripperTreats's Avatar
    Join Date
    Oct 2006
    Thanked 0 Times in 0 Posts
    Where you have
    emoticons/$smile.gif' + 'alt=$smile'); return false;
    there is nothing between smile.gif and alt. You don't need to break apart the two strings. you could try ....smile.gif \"alt=.....
    Psychedelic digital art at www.trippertreats.com.

    "And in the end, the love you take
    is equal to the love you make


    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts