Skip to content

Instantly share code, notes, and snippets.

@ranbena
ranbena / style.css
Created November 27, 2012 08:32
Modify tap highlight color
a {
-webkit-tap-highlight-color: color;
}
@ranbena
ranbena / adb.sh
Created November 27, 2012 08:37
Android console logging command
sudo android-sdk-path/platform-tools/adb logcat
@ranbena
ranbena / style.css
Created November 27, 2012 08:39
Disable image download behaviour
img {
-webkit-touch-callout: none;
}
@ranbena
ranbena / index.html
Created November 27, 2012 08:42
Mobile web inner scrolling
<div id="scroll">
This is the scrollable content
</div>
@ranbena
ranbena / style.css
Created November 27, 2012 08:44
Disable text selection behaviour
selector {
user-select: none;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
}
@ranbena
ranbena / basic.js
Created November 27, 2012 19:27
Hiding the address bar
function hideAddressBar() {
window.setTimeout(function(){
window.scrollTo(0,0);
}, 0);
}
@ranbena
ranbena / landscape-fullscreen-event.js
Created December 19, 2012 06:13
Going fullscreen
// attach to window resize event
window.addEventListener("resize", function(e) {
// determine current orientation
var isLandscape = Math.abs(window.orientation) == 90;
if (isLandscape) {
// do something
}
});
@ranbena
ranbena / index.html
Created December 19, 2012 11:25
A workaround to detecting if a native app is installed on the hosting mobile device.
<button id="btn1">Open Facebook app</button>
//Open the file directly in the browser and run this script from the console
//Assumptions: The browser uses a <pre/> tag for showing the CSS code
var file = document.querySelector("pre");
var fileContent = file.innerHTML;
var newContent = fileContent.replace(/([\d.]+)(px)/g, function(m){
var measure = parseFloat(m.split("px")[0]);
var newMeasure = measure / 10;
newMeasure = newMeasure.toFixed(2);
newMeasure = newMeasure.replace(/(\.[0-9]*?)0+$/, "$1"); // remove trailing zeros
@ranbena
ranbena / index.html
Created December 26, 2012 17:08
High density display
<html>
<head>
...
<link rel='stylesheet' href='retina.css' media='only screen and (min-device-pixel-ratio: 2)' />
...
</head>
<body>