Differents result for browsers

I’m having big trouble figuring out hopw to solve this. I’m trying to make an small wysigwyg editor with image insert, and everything is working greate except one thing…

When using Internet Explorer it works fine and comes out like this:

<img src="myimage.jpg style="float:left">

But when using safari or Google Chrome the same comes out like this:

<img src="myimage.jpg style=&quot;float:left&quot;">

It have replaced the “” with ".

I’m using this to insert the image after upload:

var imageURL = returnValue;
var style = ' style="float:left"';
var imageURL = imageURL+style;
test.execCommand("insertimage", imageURL);

How do I solve this???

Thanks in advance :slight_smile:

Is this script dynamically inserting images? If so its a very odd and inconsistant way to do so. The way this should be done is by using the DOM to create an IMG element and set its attributes like the example below.

// Set the element to append the new img element
// to
var ele = document.getElementById('element_id');

// Create the element
var img = document.createElement('img');

// Set the attributes
img.setAttribute('src', imageURL);
img.setAttribute('style', 'float: left;');

// Append the new child element "img"