XYZBLOG

WELCOME
« »
SuMoTuWeThFrSa
1234
567891011
12131415161718
19202122232425
2627282930
新近评论
新近留言
友情链接
  1. 友情链接 (1)
统计信息
  • 日志: 28
  • 评论: 2
  • 留言: 0
  • 链接: 1
  • 引用: 0
  • 访问: 27242
相册 普通 列表 管理
虽然17曾经建议我不要研究这种逆天的东西,但是这个东西的诱惑很大,所以还是研究了一下,在网上似乎有英文版的,但是语焉不详,而且很多人懒得看英文,所以自己写了一下,经ie,遨游,firefox测试有效,其他浏览器还请各位自行测试:
index.fla:
import flash.text.TextField;
var _txt:TextField=new TextField;
_txt.text="请用右键点我"
addChild(_txt);
var i=0;
function displayMessage() {
  i++;
  _txt.text=i+"";
}
ExternalInterface.addCallback("showMessage", displayMessage);

***************************很丑的分隔线*****************************
test.htm:
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>index</title>
<script>
//非ie----------------------------------
function mouseEvent_ns(e) {
  //alert(e.button)
  //firefox测得0是左键,1是中键,2是右键
  if (e.button ==2) {
    if (e) {
      //屏蔽弹出
      if (e.stopPropagation) {
        e.stopPropagation();
      }
      if (e.preventDefault) {
        e.preventDefault();
      }
      if (e.preventCapture) {
        e.preventCapture();
      }
      if (e.preventBubble) {
        e.preventBubble();
      }
    }
    //调用as函数
    thisMovie("index").showMessage();
  }
}
function RightMouseUp_ns(e) {
  mouseEvent_ns(e);
  return false;
}
function downRightClick_ns(e) {
  mouseEvent_ns(e);
  return false;
}
//ie----------------------------------
function mouseEvent_ie() {
  //alert(event.button)
  //1是左键,4是中键,2是右键,但不知为什么遨游里按下没反应,弹起时先是得到0再得到2,遗憾...
  if (event.button != 1&&event.button != 4) {  
    //调用as函数
    thisMovie("index").showMessage();    
    //屏蔽弹出
    thisMovie("index").openRightClick();
    parent.frames.location.replace('javascript: parent.falseframe');
  }
}
function RightMouseUp_ie() {
  mouseEvent_ie()
  return false;
}
function RightMouseDown_ie(e) {  
  mouseEvent_ie()
  return false;
}
//得到播放器对象---------------------------------------
function thisMovie(movieName) {
  if (navigator.appName.indexOf("Microsoft") != -1) {
    return window[movieName];
  } else {
    return document[movieName];
  }
}
//触发鼠标事件-----------------------------------------
this.ns = (navigator.appName == 'Netscape');
if (this.ns) {
  document.captureEvents(Event.MOUSEDOWN);
  document.addEventListener("mousedown", downRightClick_ns, true);
  document.captureEvents(Event.MOUSEUP);
  document.addEventListener("mouseup", RightMouseUp_ns, true);
} else {
  document.onmousedown = RightMouseDown_ie;
  document.onmouseup = RightMouseUp_ie;
}

</script>
</head>
<body bgcolor="#ffffff" topmargin="0" leftmargin="0" marginwidth="0">
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="900" height="500" id="index" align="middle">
   <param name="allowScriptAccess" value="sameDomain" />
   <param name="movie" value="index.swf" />
   <param name="menu" value="false" />
   <param name="quality" value="high" />
   <param name="wmode" value="opaque" />
   <param name="bgcolor" value="#ffffff" />
   <embed src="index.swf" menu="false" quality="high" wmode="opaque" bgcolor="#ffffff" width="900" height="500" name="index" align="middle" allowscriptaccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />  
</object>
</body>
</html>
***************************很丑的分隔线*****************************
细心的人还会发现ie里鼠标点快了会有检测丢失的情况,又一遗憾,不过总归可以稍微利用下了吧
测试地址:
090302_test.htm
http://127.0.0.1/blog/trackback.asp?q=597716227
姓名: 密码:
主页: 私密:

验证码:
    1  2  3  4  5  6  7  8  9  10