页面右键动作禁用

让页面没有地址栏、状态栏、工具栏

l  ie中必须将域名或者ip添加到可信任。不然地址栏去不掉。

l  在登录页或者系统入口页中弹出窗口并关闭原窗口。

(function() {

                    var url = window.location.href;

                    if(url.indexOf('isreload')==-1){

                        if (url.indexOf("\?") != -1) {

                             url=url.substring(0,url.indexOf("\?"));

                        }

                        url += "?isreload=1";

                        var newWindow = window.open(url,'loginWindow','toolbar=no,location=no,directories=no,menubar=no,scrollbars=yes,resizable=yes,status=no');

                        newWindow.moveTo(0, 0);

                        newWindow.resizeTo(screen.availWidth, screen.availHeight);

                        window.open('close.html', '_self');

                        return;

                    }

                  })();

 

 

 

Close.html

<html><body>

<script type="text/javascript">window.close();</script>

</body></html>

 

 

 

l  session失效、注销系统等返回系统入口页时,主要要在跳转url中加上isreload标识,不然会导致入口页面关闭。

 

l  目前还存在标题栏中会保留URL的问题。因为安全限制原因,标题栏中的URL和地址栏必须有一个存在。如果系统允许全屏显示,可以通过页面的全屏显示来屏蔽此问题。但是也没有从根本上解决,只是不显示标题栏了。

禁用右键菜单、前进、后退、页面刷新

l  在页面的onload事件中添加如下处理。

 


function my_disable_button(){

    window.history.forward(1);

    var message="Sorry, right-click has been disabled";

    //alert("it is coming!!");

    /// Functions

    function clickIE() {

      if (document.all && (event.srcElement.form == null || event.srcElement.isTextEdit == false)) {

        return false;

      }

    } 

    

    function clickNS(e) {

      if (document.layers||(document.getElementById&&!document.all)) { 

        if (e.which==2||e.which==3) {

          return false;

        }

      }

    } 

    

    function cancelBack(){

      //alert(message);

      if(window.event && window.event.keyCode == 116)

      { // Capture and remap F5

        window.event.keyCode = 505;

      }

      if(window.event && window.event.keyCode == 505){ // New action for F5

        return false;

        // Must return false or the browser will refresh anyway

      }  

      

      // 8 backspace, 37 left arrow, 39 right arrow, 116  F5, 122 F11, CTRL-N, CTRL-R

      if( (

             (window.event.keyCode == 8) 

          || (window.event.keyCode == 37 && window.event.altKey) 

          || (window.event.keyCode == 39 && window.event.altKey)

          )

      && (event.srcElement.form == null || event.srcElement.isTextEdit == false))

      {

        event.cancelBubble = true;

        event.returnValue = false;

        //alert('Backspace, Alt+leftarrow, or Alt+rightarrow called');

      } else if(

             (window.event.keyCode == 116 )

          || (window.event.keyCode == 122)

          || (window.event.ctrlKey && (window.event.keyCode == 78 || window.event.keyCode == 82))){

        event.cancelBubble = true;

        event.returnValue = false;

        //alert('F5, F11, Ctrl+N, or Ctrl+R called');

      }      

    }

    /// Calls

    document.οncοntextmenu=new Function("return false");

    if (document.layers) {

      //alert("flag 1.");

      document.captureEvents(Event.MOUSEDOWN);

      document.οnmοusedοwn=clickNS;

    } else {

      //alert("flag 2.");

      document.οnmοuseup=clickNS;

      document.οncοntextmenu=clickIE;

    } 

    document.οnkeydοwn=cancelBack;

}

 

 

 

l  注意在ADF框架中,需要将af:document组件的clientCompenent属性设置为true,然后触发af:clientListener中的onload事件。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值