Search code examples
jqueryiframeexeccommand

How to execute "execCommand" in an iFrame with jQuery?


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?


Solution

  • I found the answer here.

    In my case (jQuery). It looks like

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