iframe を含むページがあります。ユーザーがx秒間アクティブでない場合(keydownとmousemoveがない場合)、ページがホームページにリダイレクトされるコードを配置しました。私の問題は、コードがマザーページでのみ機能するが、iframe で mousemove と keydown を検出しないため、アクティビティにもかかわらず iframe 内で毎回リダイレクトされることです。iframe の onload イベントで関数を呼び出してみましたが、うまくいきません。ページのコードは次のとおりです。
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>SAMPLE</title>
<link href="main.css" rel="stylesheet" type="text/css" media="screen" />
<script language="javascript">
function redirect()
{
var timer;
window.onload= document.onmousemove= document.onkeypress= function(){
clearTimeout(timer);
timer=setTimeout(function(){location= 'index.html'},3000);
}
}
</script>
</head>
<body bgcolor="blue" onLoad="redirect();">
<iframe src="http://tplink.teleperformanceusa.com" frameBorder="0" width="100%" height="800px" onLoad="redirect();"></iframe>
...
</body>
</html>
任意の助けをいただければ幸いです。ありがとうございました!