htmlArea

A directory of browser-based WYSIWYG editors

  MAIN
INDEX
SEARCH
POSTS
WHO'S
ONLINE
LOG
IN

Home: WYSIWYG Forums: WYSIWYG Editor Discussion:
Urgent help Please, Insert image inside div tag


 


dirarko
Novice

Oct 6, 2005, 2:02 AM

Post #1 of 2 (20793 views)
Shortcut
Urgent help Please, Insert image inside div tag Can't Post

hello,

I am trying to insert an Image inside a div tag, in order to display description of the image under it, I managed to insert the image inside the div, and the code looks like this:

<div style="FLOAT: left">
<img height="320" alt="Image description" hspace="10" src="SRC..."
width="240" align="bottom" vspace="10" border="0"/><br />Image description
</div>

what I did I replace the insertImage function with this:

HTMLArea.prototype._insertImageTest = function(image) {
......

if (!img) {
var sel = editor._getSelection();
var range = editor._createRange(sel);
var doc = editor._doc;
var div = doc.createElement("div");
var img = doc.createElement("img");
img.src = param.f_url;
div.appendChild(img);
div.appendChild(doc.createElement("br"));
div.appendChild(doc.createTextNode(param["f_alt"]));
div.style.float = param["f_align"];
for (field in param) {
var value = param[field];
switch (field) {
case "f_alt" : img.alt = value; break;
case "f_border" : img.border = parseInt(value || "0"); break;
case "f_align" : img.align = "bottom"; break;
case "f_vert" : img.vspace = parseInt(value || "10"); break;
case "f_horiz" : img.hspace = parseInt(value || "10"); break;
}
}
range.pasteHTML(div.outerHTML);
}
}, outparam);



I am not sure if this is the best way to do it, but instead of selecting the image, I am trying to select the DIV and not the image, and when trying to edit the image the image information should appears right.

Would appreciate any help


dirarko
Novice

Nov 21, 2005, 1:56 AM

Post #2 of 2 (20545 views)
Shortcut
Re: [dirarko] Urgent help Please, Insert image inside div tag [In reply to] Can't Post

I'v solved the problem by making the contentEditable of the div equals to false, also made some changes to the function so it looks better.

 
 
 


Search for (options)