最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Finding when an Iframe's content changes when in designMode - Stack Overflow

programmeradmin2浏览0评论

I have an Iframe which I have enabled designMode on. Quite simply I would like to have a callback function called if the cursor in the Iframe moves or content changes. It seemed quite simple at first but I can't use onchange/ onkeyup on the Iframe.

I assume I need to add an event to a member of the Iframe. I've tried

frames['writer'].document.body.onkeyup = eventHandler

to no success.


Update

I've found that setting designMode = 'on' is causing the problems. If I ment out the line that sets designMode to 'on' then handling events works fine.

I have an Iframe which I have enabled designMode on. Quite simply I would like to have a callback function called if the cursor in the Iframe moves or content changes. It seemed quite simple at first but I can't use onchange/ onkeyup on the Iframe.

I assume I need to add an event to a member of the Iframe. I've tried

frames['writer'].document.body.onkeyup = eventHandler

to no success.


Update

I've found that setting designMode = 'on' is causing the problems. If I ment out the line that sets designMode to 'on' then handling events works fine.

Share Improve this question edited Jul 14, 2011 at 18:28 Robert Harvey 181k48 gold badges348 silver badges513 bronze badges asked Apr 16, 2009 at 22:24 PythonPowerPythonPower
Add a ment  | 

2 Answers 2

Reset to default 6

OK, I have a solution:

if(document.addEventListener)
{
    frames['writer'].document.addEventListener('keyup', updateStatus, false);
    frames['writer'].document.addEventListener('mouseup', updateStatus, false);
}

It works a charm!

Try writing a function called document.onkeyup:

function document.onkeyup() {
  // do stuff
}

I've never seen that style before, but that was just something I found on Google...

发布评论

评论列表(0)

  1. 暂无评论