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中不可編輯