zoukankan      html  css  js  c++  java
  • 限制页面只能在框架页中

    JavaScript代码
    1.    <script language="javascript" type="text/javascript">   
    2.    if (top.location == self.location) {    
    3. thisSLoc = self.location.href;     
    4. tmpHPage = thisSLoc.split( "/" );     
    5. thisHPage = tmpHPage[ tmpHPage.length-1 ];     
    6. strwrite =   thisHPage ;   
    7. strwrite=strwrite.replace(/?/g,"%3F");   
    8. strwrite=strwrite.replace(/=/g,"%3D");   
    9. strwrite=strwrite.replace(/&/g,"%26");   
    10.        top.location='default.php' + '?main=' +strwrite;   
    11.    }    
    12.    </script>  

    采用这样就可以把页面返回给首页,然后用main=参数进行框架页地址处理。现在《中国医药库》已经在使用,访问地址:www.zgyyk.com,测试地址:http://www.zgyyk.com/show.php?id=272 ,作者:何博文

    这样不但可以限制用户只能在框架页中访问,还能自动切换到用户访问的原始页面,提高用户体验,很不错的解决方案。

    要是大家不需要在框架中直接访问用户原先的请求页,只需要使用代码:

    JavaScript代码
    1. <script language="javascript" type="text/javascript">   
    2. if (top.location == self.location) {    
    3.     top.location='default.php';   
    4. }    
    5. </script>  
  • 相关阅读:
    索引压缩
    拼写校正
    词典(词汇表)
    Text Relatives II
    Text Relatives
    CoreText
    Quartz2D Text
    PDF Document Creation, Viewing
    Core Graphics Layer Drawing
    Bitmap Images and Image Masks
  • 原文地址:https://www.cnblogs.com/accumulater/p/6768847.html
Copyright © 2011-2022 走看看