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

时间:2010-09-15 06:26:39

标签: asp.net

帮助我, 我想在我的asp.net网站上隐藏我的地址栏网址。

5 个答案:

答案 0 :(得分:5)

试试这个

window.open('MyPage.aspx','Title','toolbar=no,status=no,resizable=1,scrollbars=1,menubar=no,location=no,width='+screen.width+',height=700'); 

答案 1 :(得分:1)

如今大多数浏览器似乎都会覆盖此行为。例如Firefox:see this

答案 2 :(得分:1)

这似乎工作得很好 - 请参阅Scott J的这篇文章...即javascript函数 - iOS和&的标准化隐藏地址栏。机器人:

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

我让它在.Net .master页面内正常工作(需要设置身体的最小高度。) 即在.master页面中,添加以下内容:

<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 :(得分:0)

您可以使用javascript而非Asp.net隐藏地址栏

window.document.statusbar.enable = false;

答案 4 :(得分:0)

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

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上工作。

相关问题