how to include css and javascript in iFrame

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 ?

链接地址: http://www.djcxy.com/p/89952.html

上一篇: 如何手动执行WYMeditor函数没有错误?

下一篇: 如何在iFrame中包含CSS和JavaScript