How can I pass the onorientationchange()
event to iframe-开发者_JAVA百科based sites?
Try this:
window.addEventListener('load', function(){
if (self != top) {
window.top.location = window.self.location;
}
window.onorientationchange = function () {
switch (window.orientation) {
case 0:
alert('PORTRAIT');
break;
case 90:
alert('LANDSCAPE');
break;
case -90:
alert('LANDSCAPE');
break;
}
}
}
精彩评论