for example:

i click a button. And a div is changeing someting

$('#change').click(function(){ //the button
  $('#myframe').contents().find('#makeit').css("do Someting") //the div in a frame
});

So far i've understand.

I need to know, how can i execute an execCommand (maybe like 'bold') instead of a .css() methode?

有帮助吗?

解决方案

I found the answer here.

In my case (jQuery). It looks like

$('#change').click(function(){
   document.getElementById("myframe").contentWindow.document.execCommand('bold', false, null);
});

其他提示

You want to target execCommand() on an element with id "makeit"?

I'm afraid that's not possible, since it's document.execCommand(String commandName, Bool showUI, Variant value) which executes the command based on the selection / caret focus.

Read eg. https://developer.mozilla.org/en-US/docs/Rich-Text_Editing_in_Mozilla for details.

I forgot to mention the div is contendeditable="true". i want to change the content in the div(id="makeit"). which is in a iframe

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top