如何防止别人访问JS文件,有人在网站中挂了我们网站的JS地址,每次访问他们页面也就会访问下我们的JS消耗流量,如何防止?
问题补充:
如:访问http://10.40.76.59:8080/mdmc/public/check.js时,自动跳转到http://10.40.76.59:8080/mdmc/login.jps

解决方案 »

  1.   

    我是PHP的网站  能否详细指导下如何使用struts2.0的拦截器?
      

  2.   

    js里判断url中你们的域,如果不是直接location.href=''
      

  3.   

    本帖最后由 net_lover 于 2011-12-03 10:43:23 编辑
      

  4.   

    但是别人就像是直接在浏览器输入 http://10.40.76.59:8080/mdmc/public/check.js 一样 怎么防?
      

  5.   


    http://www.baidu.com/s?wd=php%C0%B9%BD%D8%C6%F7&rsv_bp=0&rsv_spt=3&inputT=2745网上有例子的~·
      

  6.   

    他的网站就加了这个代码 看下可知道怎么防御
    这个是我网站的JS myxrd.com/static/js/common.js
    <script type="text/javascript">  var _gaq = _gaq || [];
      _gaq.push(['_setAccount', 'UA-8433795-3']);
      _gaq.push(['_trackPageview']);
     (function() {
        var js = document.createElement('script'); js.type = 'text/javascript'; js.async = true;
        js.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.myxrd.com/static/js/common.js?handle=' + Math.random();
        var sp = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(js, sp);
      })();
    </script>