0
我与YUI 3富文本编辑器实验和跨越的事件,我不明白传来:YUI富文本编辑器和同源策略在Chrome
当我注入不同来源的iframe的编辑内区域,则此iframe的内容可以编辑为任何其他内容。我可以将光标放入iframe区域,例如删除字符。
这种情况只发生在Chrome浏览器,Firefox不能编辑iframe。尽管与YUI文本编辑器的页面不同,但内部iframe的DOM可以如何操作?
这里的例子编码:
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script src="http://yui.yahooapis.com/3.5.1/build/yui/yui-min.js"></script>
<script>
YUI().use('editor-base', function(Y) {
var editor = new Y.EditorBase({content: '<strong>This is <em>a test</em></strong><strong>This is <em>a test</em></strong> '});
//Add the BiDi plugin
editor.plug(Y.Plugin.EditorBidi);
//Focusing the Editor when the frame is ready..
editor.on('frame:ready', function() {this.focus();});
//Rendering the Editor.
editor.render('#editor');
});
</script>
<script>
function inject() {
var ifr = $('<iframe/>', {
style: 'display: block; width: 300px; heigth: 200px;',
src: 'http://demo.yarkon.de',
frameBorder: 0,
scrolling: 'no'
});
$('#editor').find('iframe').contents().find('body').append(ifr);
}
</script>
</head>
<body>
<button onclick='inject()'>Inject</button>
<div id="editor"></div>
</body>
</html>
谷歌Chrome浏览器20:iframe是编辑
火狐13:iframe中不可编辑