开发者

call function on iframe mouse move

I have a function that i need to call on iframe mousemove(). But i didnt found anything like we h开发者_Go百科ave in body tag We have <body mousemove="Function()"> Do we have anything like this for iframe??


The iframe contains its own document, own body element etc. Try something like this:

var frame = document.getElementById("yourIframeId");
// IE is special
var frameDoc = frame.contentDocument || frame.contentWindow.document;
var frameBody = frameDoc.getElementsByTagName("body")[0];

var testingOneTwo = function() {
    console.log("Hello, is this thing on?");
};
frameBody.onmouseover = testingOneTwo;


Did you mean onMouseOver or onFocus?

e.g.

<HTML>
 <HEAD>
  <TITLE> New Document </TITLE>  
  <script language="javascript">
  <!--
function SayHello()
{
 alert("Hi from IFrame");
}

  //-->
  </script>
 </HEAD>

 <BODY>
 <iframe id="myiFrame" onMouseOver="SayHello()"/>
<iframe id="myiFrame" onFocus="SayHello()"/>
 </BODY>
</HTML>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜