Reputation: 7053
I have got a table, on a page:
<table border="0" width="320px" height="480px" style="background-color: black;">
UPDATE:
I want to remove the search bar above... so this is all I used for the adaptation for the mobile:
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta names="apple-mobile-web-app-status-bar-style" content="black-translucent" />
<title></title>
<style type="text/css">
body{
margin:0px;
padding: 0px;
}
</style>
<script>
window.addEventListener("load",function() {
// Set a timeout...
setTimeout(function(){
// Hide the address bar!
window.scrollTo(0, 1);
}, 0);
});
</script>
</head>
I still can see one inch of the navigation bar..but I am trying to remove that one inch but cant
Upvotes: 1
Views: 2113
Reputation: 104
This site also has a few other suggestions, but this no-nonsense, no-worry one is available in a github:gist and answers your question (pasted here for convenience):
function hideAddressBar()
{
if(!window.location.hash)
{
if(document.height < window.outerHeight)
{
document.body.style.height = (window.outerHeight + 50) + 'px';
}
setTimeout( function(){ window.scrollTo(0, 1); }, 50 );
}
}
window.addEventListener("load", function(){ if(!window.pageYOffset){ hideAddressBar(); } } );
window.addEventListener("orientationchange", hideAddressBar );
As far as I can tell, the combination of extra height added to the page (which caused problems for you) and the scrollTo() statement make the address bar disappear.
From the same site the 'simplest' solution to hiding the address bar is using the scrollTo() method:
window.addEventListener("load", function() { window.scrollTo(0, 1); });
This will hide the address bar until the user scrolls.
This site places the same method inside a timeout function (the justification is not explained, but it claims the code doesn't work well without it):
// When ready...
window.addEventListener("load",function() {
// Set a timeout...
setTimeout(function(){
// Hide the address bar!
window.scrollTo(0, 1);
}, 0);
});
Upvotes: 0
Reputation: 278
as to hiding the navigation bar, scrolling the page to 0 will only work if you have enough height to your page to fill the remaining space. I sometimes use javascript to rezise and resize back, before and after the scrolling,
function scrollWinToTop () {
document.body.style.height = (window.innerHeight *1.5) + 'px'; //a lot of pixels or a large precentage
window.scrollTo(0, 1); // moves the viewport to the top
document.body.style.height = 'auto'; // OR clientHeight + 'px' OR something
}
Upvotes: 0
Reputation: 7053
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=1;" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta names="apple-mobile-web-app-status-bar-style" content="black-translucent" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script>
<title>Your <?php echo $app_name; ?> </title>
<style type="text/css">
body{
margin:0px;
padding: 0px;
}
/* i assume portrait to be the starting point */
</style>
<script>
window.addEventListener("load",function() {
// Set a timeout...
setTimeout(function(){
// Hide the address bar!
window.scrollTo(0, 1);
}, 0);
});
var preventDefault = function(e) {
e.preventDefault();
return false;
};
document.addEventListener('touchmove',preventDefault,false);
document.body.addEventListener('touchmove',preventDefault,true);
window.addEventListener('touchmove',preventDefault,true);
</script>
</head>
Thats what I wanted.. no navigation , and disable all events
Upvotes: 0
Reputation: 278
try using media queries for different css rules based by orientation:
/* i assume portrait to be the starting point */ .element{ rule:value; } @media (orientation: landscape) { .element{ rule:different value; } }
but consider designing something more responsive perhaps
Upvotes: 1