代码之家  ›  专栏  ›  技术社区  ›  parmarupendra

我可以隐藏我们的地址栏网址吗asp.net

  •  2
  • parmarupendra  · 技术社区  · 16 年前

    帮助我, 我想在我的asp.net网站。

    5 回复  |  直到 16 年前
        1
  •  5
  •   Pankaj Mishra    16 年前

    试试这个

    window.open('MyPage.aspx','Title','toolbar=no,status=no,resizable=1,scrollbars=1,menubar=no,location=no,width='+screen.width+',height=700'); 
    
        2
  •  1
  •   Brian Wells    14 年前

    这似乎很管用-看这篇来自斯科特J。。。i、 e.javascript函数-iOS和Android规范化隐藏地址栏:

    http://24ways.org/2011/raising-the-bar-on-mobile

    我让它在.Net.master页面中正常工作(需要设置主体的最小高度) i、 e.在母版页中,添加以下内容:

    <style type="text/css">body {min-height: 480px;}</style>
    
    <script type="text/javascript">
    /*
      * Normalized hide address bar for iOS & Android
    */
    (function( win ){
        var doc = win.document;
    
        // If there's a hash, or addEventListener is undefined, stop here
        if( !location.hash && win.addEventListener ){
    
            //scroll to 1
            window.scrollTo( 0, 1 );
            var scrollTop = 1,
                getScrollTop = function(){
                    return win.pageYOffset || doc.compatMode === "CSS1Compat" && doc.documentElement.scrollTop || doc.body.scrollTop || 0;
                },
    
                //reset to 0 on bodyready, if needed
                bodycheck = setInterval(function(){
                    if( doc.body ){
                        clearInterval( bodycheck );
                        scrollTop = getScrollTop();
                        win.scrollTo( 0, scrollTop === 1 ? 0 : 1 );
                    }   
                }, 15 );
    
            win.addEventListener( "load", function(){
                setTimeout(function(){
                    //at load, if user hasn't scrolled more than 20 or so...
                    if( getScrollTop() < 20 ){
                        //reset to hide addr bar at onload
                        win.scrollTo( 0, scrollTop === 1 ? 0 : 1 );
                    }
                }, 0);
            } );
        }
    })( this );
    </script>
    

    完整的脚本可以在Github上找到(完整源代码: https://gist.github.com/1183357 ).

        3
  •  1
  •   Erwin Bolwidt    12 年前

    现在大多数浏览器似乎都忽略了这种行为。例如Firefox: see this

        4
  •  0
  •   anishMarokey FIre Panda    16 年前

    您可以使用隐藏地址栏 javascript 不是通过Asp.net

    window.document.statusbar.enable = false;
    
        5
  •  0
  •   Darin Dimitrov    16 年前

    您可以尝试关闭当前窗口,然后打开一个新窗口:

    var dimensions = 'toolbars=no,menubar=no,location=no,scrollbars=yes,resizable=yes,status=yes';
    window.opener = self;
    window.close();
    window.open('http://example.com/foo.htm', '_blank', dimensions);
    window.moveTo(0, 0);  
    window.resizeTo(screen.width, screen.height - 100);
    

    不能保证是跨浏览器的。它似乎正在研究IE。

    推荐文章