<object>

73 views
Skip to first unread message

Flavio Duarte

unread,
Oct 7, 2010, 3:57:30 PM10/7/10
to cleditor
Hi
I'm writing a plugin and i'm trying to insert a tag <object> into the
editor with execCommand "inserthtml"
but isn't work, and a tried to insert the tag <p> with "inserthtml"
and it work

why I cant insert the object tag? some special reason?

Chris Landowski

unread,
Oct 7, 2010, 4:30:54 PM10/7/10
to cled...@googlegroups.com
A code sample might help to get your question answered quicker.

Flavio Duarte

unread,
Oct 8, 2010, 6:56:00 AM10/8/10
to cleditor
var $text = $(data.popup).find(":text"),
url = $text[0].value;
var novaurl = url.split('=')[1].split('&')[0];

var html = '';
html = '<object width="480" height="385"> ';
html += '<param name="movie" value="http://www.youtube.com/v/'+novaurl
+'"></param>';
html += '<param name="allowFullScreen" value="true"></param><param
name="allowscriptaccess" value="always"></param>';
html += '<embed src="http://www.youtube.com/v/'+novaurl+'"
type="application/x-shockwave-flash" allowscriptaccess="always"
allowfullscreen="true" width="480" height="385"></embed>';
html += '</object>';

// Insert the html
if (html)
editor.execCommand(data.command, html, null, data.button);

I was testing and this code works with ie8 and chrome, with firefox no
if we fix this problem I can merge this plugin into project

Chris Landowski

unread,
Oct 8, 2010, 9:00:29 AM10/8/10
to cled...@googlegroups.com
I did a little testing and it does appear that Firefox will not insert an
object tag using the execCommand method and the inserthtml command.

If you are simply trying to embed a youtube video into the document, you
could insert an iframe object instead. See the following link for an
example:
http://groups.google.com/group/cleditor/browse_thread/thread/15b3747b25fc3f7
/886dc0de0ff0c407?lnk=gst&q=youtube#886dc0de0ff0c407

Your html would look something like this:
<iframe class="youtube-player" type="text/html" width="480"
height="385" src="http://www.youtube.com/embed/5-XEa2zVjAg"
frameborder="0"></iframe>

If you absolutely must use an object tag, you could insert an object element
directly into the iframe DOM at the location pointed to by the current range
object within the document.

Hope this helps,
Chris

Flavio Duarte

unread,
Oct 8, 2010, 9:19:11 AM10/8/10
to cled...@googlegroups.com
I tested this solution.
The embed doesn't work inserting with toolbar plugin, and the iframe too, only if I insert the code with html editor. Can I send the plugin code to your email for you see how it's working?
The problem isn't the preview, the problem is that the html isn't inserted with my plugin


2010/10/8 Chris Landowski <chrisla...@gmail.com>

Chris Landowski

unread,
Oct 8, 2010, 4:49:21 PM10/8/10
to cled...@googlegroups.com

After some additional testing, I believe that I have found the problem. It appears that in Firefox version 3.6.10, a change was made to the browsers execCommand method which prevents the inserthtml command from inserting both object and iframe tags. All other tags that I tested appear to work just fine. I also tested several older versions of Firefox and they do not exhibit this problem. If you look at the link I posted in my previous reply, you will see that this was working fine on September 26th. Since then, I had upgraded to 3.6.10 and now it will not work.

 

As a work around, you could get the range object of the document within the iframe to determine the parent node and offset, then manually create the element from the html string and insert it into the DOM. This should work on all W3C compliant browsers and IE could continue to use the inserthtml command.

 

After I release the next version, I was thinking about adding a custom youtube plugin, but that might be a ways off.

 

Hope this helps,

Chris

Reply all
Reply to author
Forward
0 new messages