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

I have an Iframe which I have enabled designMode on. Quite simply I would like to have a callback funct

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...

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745573379a4633817.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信