View Full Version : Modifying an onclick link

01-10-2007, 01:27 AM
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. (:

01-12-2007, 06:18 AM
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=.....

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum