获取光标对象?????????????????????????????????????第一次听说如果是失去焦点然后提示信息还可以
ie的话直接加个onblur
<html>
<head>
</head>
<body>
<iframe id="ifm" style="width:300px;height:100px;" onblur="alert('gg')"> </iframe>
</body>
</html>
如果上ff的话因为iframe没有onblur,可以使用event来模拟onblur事件,可以参考这里,因为ff下div也没有onblur
ff下div失去焦点无效果
ie的话直接加个onblur
<html>
<head>
</head>
<body>
<iframe id="ifm" style="width:300px;height:100px;" onblur="alert('gg')"> </iframe>
</body>
</html>
如果上ff的话因为iframe没有onblur,可以使用event来模拟onblur事件,可以参考这里,因为ff下div也没有onblur
ff下div失去焦点无效果
可能是我没说清楚,我要在焦点离开iframe的时候,获取光标在当前iframe所在位置.
<html>
<head>
</head>
<body>
<iframe id="ifm" style="width:300px;height:100px;"></iframe>
<script>
var ifm,c;
window.onload=function()
{
ifm=document.getElementById("ifm");
c=ifm.contentWindow;
c.document.designMode="on";
c.document.open();
c.document.write("<html><head></head><body></body></html>");
c.document.close();
c.document.body.contentEditable="true";
ifm.focus();
}
document.onmousedown=lostFocus;
function lostFocus()
{
if(c.document.selection)//ie
{
c.focus();
var r=c.document.selection.createRange();//range对象
alert(r.text);//输出选种的文本
}
else if(c.document.createRange)//ff
{
c.focus();
var r=c.document.createRange();//range对象
alert(typeof(r));
}
}
</script>
</body>
</html>