防止盗链问题:Javascript从A页面跳到B页面,B页面无法获取A页面网址来源,即B页面的Request.UrlReferrer为null

    技术2022-05-19  19

    以下两种常用的页面跳转在IE下无法获取:

     

    1) window.open('PageB.aspx'), PageB.aspx中的Request.UrlReferrer为空

     

    2) window.location.href='PageB.aspx', PageB.aspx中的Request.UrlReferrer为空

     

    解决办法:

    在A页面中添加一行HTML代码<a id="clickme" href="PageB.aspx"></a>,然后用js模拟一次用户点击这个链接的事件。

    <mce:script type="text/javascript"><!-- function doClick(){ var link = document.getElementById('clickme'); if (link){ link.click(); } } // --></mce:script>        

     


    最新回复(0)