Domanda

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?

È stato utile?

Soluzione

I found the answer here.

In my case (jQuery). It looks like

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

Altri suggerimenti

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

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top