javaScript:动态添加iframe src内容

 //定义一iframe
var RichEdit   = '';
 

 //把它替换为 iframe
 var editor_obj = document.all["_" +objname + "_editor"]; //获取页面某object ,默认为textarea
editor_obj.outerHTML = RichEdit;

 //添加html 到 iframe
var html = "";
 var html_href='A {target:expression(this.target=/"_blank/");background-color: Silver;}/n';
 alert('html_href: '+html_href);
    html += '/n';
    if (config.stylesheet) {
      html += '/n';
    }
    html += '/n'

      + '/n'
      + '

// still working on this
//      + ' οncοntextmenu="parent.editor_cMenu_generate(window,/'' +objname+ '/');"'
      +'>'
      + contents
      + '/n'
      + '/n';

    // write to editor window
   
var editdoc = editor_obj.contentWindow.document;  //获取当前iframe 的document

    editdoc.open();
    editdoc.write(html); //添加html 到 iframe
    editdoc.close();

你可能感兴趣的:(javaScript:动态添加iframe src内容)