JQUERY竞争到iFRAME

我正在尝试构建一个“JS确认下面离开页面function”

我遇到的问题是在页面上我需要这个确认function我正在使用CKEDITOR为文本编辑器创建一个iframe。

// Javascript code that controls the onbeforeunload event function setConfirmUnload(on) { window.onbeforeunload = (on) ? unloadMessage : null; } function unloadMessage() { return 'You have entered new data on this page. If you navigate away from this page without first saving your data, the changes will be lost.'; } // JQuery code to the page with the form that we would like to control: $(document).ready(function() { $(':input',document.newnote).bind("change", function() { setConfirmUnload(true); }); // Prevent accidental navigation away }); 

我如何绑定iframe,所以脚本会捕获iframe中的更改?

这是iFrame CKEDITOR创建的:

 
.cke_skin_kama{visibility:hidden;}

像这样:

 $(':input', document.newNote.contentWindow.document).change(...); 

假设document.newNote是IFRAME。