How to set document.domain for a dynamically generated IFRAME?

后端 未结 1 1238
滥情空心
滥情空心 2020-12-24 10:10

I am implementing CodeMirror (http://marijn.haverbeke.nl/codemirror/) on a page where document.domain needs to be declared (because of other IFRAMES on the page).

Co

相关标签:
1条回答
  • 2020-12-24 10:36

    Got it to work, finally. A hack inspired by TinyMCE code.

    var u = 'javascript:(function(){document.open();document.domain="' + document.domain + '";var ed = window.parent.CodeMirror_boilerplate;document.write(ed);document.close();})()';
    

    frame.src = u;

    It sets the document.domain in SRC and not by DOM.

    0 讨论(0)
提交回复
热议问题