开发者

can i hide our address bar url in asp.net

开发者 https://www.devze.com 2023-01-16 00:34 出处:网络
help me, i want to hide my address bar url in开发者_C百科 my asp.net website.Try This window.open(\'MyPage.aspx\',\'Title\',\'toolbar=no,status=no,resizable=1,scrollbars=1,menubar=no,location=no,widt

help me, i want to hide my address bar url in开发者_C百科 my asp.net website.


Try This

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


This seems to work pretty well - see this article from Scott J... i.e. javascript function - Normalized hide address bar for iOS & Android:

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

I got this to work fine inside a .Net .master page (needed to set min-height of the body of the body.) i.e. in the .master page , add the following:

<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>

The completed script can be found on Github (full source: https://gist.github.com/1183357 ).


Nowadays most the browsers seem to override this behavior. For example Firefox: see this.


you can hide the address bar using javascript not by Asp.net

window.document.statusbar.enable = false;


You may try closing the current window and then opening a new:

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);

Not guaranteed to be cross browser. It appears to be working on IE.

0

精彩评论

暂无评论...
验证码 换一张
取 消