Created
April 9, 2012 15:28
-
-
Save neonstalwart/2344240 to your computer and use it in GitHub Desktop.
dojo/hash in android
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html class="mobile dj_phone android_theme"> | |
<head> | |
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no"/> | |
<title>Populizr Mobile</title> | |
<link rel="stylesheet" href="populizr.css" type="text/css" /> | |
<link rel="stylesheet" href="js/release/dojo/dojox/mobile/themes/android/android.css" type="text/css" /> | |
</head> | |
<body> | |
<h1>test</h1> | |
<div id="output"></div> | |
<script src="http://ajax.googleapis.com/ajax/libs/dojo/1.7.2/dojo/dojo.js" type="text/javascript"></script> | |
<script type="text/javascript"> | |
require(['dojo/_base/kernel', 'dojo/topic', 'dojo/hash', 'dojo/aspect', 'dojo/domReady!'], function (kernel, topic, dHash, aspect) { | |
function log() { | |
buffer += Array.prototype.join.call(arguments, ' ') + '<br>'; | |
output.innerHTML = buffer; | |
} | |
var buffer = '', | |
output = document.getElementById('output'); | |
log('READY...'); | |
topic.subscribe('/dojo/hashchange', function (hash) { | |
if (hash === window.location.hash.slice(1)) { | |
log('success', hash); | |
} | |
else { | |
log('fail', hash, window.location.hash); | |
} | |
}); | |
/* | |
window.onhashchange = function (e) { | |
log('new', e.newURL); | |
log('old', e.oldURL); | |
}; | |
*/ | |
aspect.after(window, 'onhashchange', function () { | |
log('after window', window.location.hash); | |
}); | |
aspect.after(kernel.global, 'onhashchange', function () { | |
log('after global', window.location.hash); | |
}); | |
window.addEventListener('hashchange', function (e) { | |
log('addEventListener new', e.newURL); | |
log('addEventListener old', e.oldURL); | |
}, false); | |
dHash('test'); | |
window.location.hash = 'rawTest'; | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment