how to include css and javascript in iFrame

…衆ロ難τιáo~ 提交于 2020-01-06 02:47:07

问题


My css and javascript aren't taken into consideration in iframes. For example I've this iframe :

<iframe name="richTextField" id="richTextField"/>

Where I inject a .css file after page load:

$(document).ready(iFrameOn);

function iFrameOn() {
    richTextField.document.designMode = "On";
    richTextField.document.head.innerHTML = '<link rel="stylesheet" type="text/css" href="iframe.css">';
}

In chrome the head of my iframe will contain my stylesheet but it won't have any effect, in ie it's not even included.

Anyway I noticed that alert doesn't work for me on jsfiddle while it works for other users. Take this code for instance. No alert dialog appears for me on chrome. I think this might be linked. Any idea why this would happen ?

来源:https://stackoverflow.com/questions/32530638/how-to-include-css-and-javascript-in-iframe

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!