動作するWebページを作成しましたが、jscriptを外部ファイルに取り込もうとすると、呼び出されなくなります。ファイル名を含めるためにヘッダーにコードを挿入しましたが、それでも呼び出すことができません。これが私のjscriptです。ちょっと編集してください。ここからisMobile関数を取得しました。http: //www.abeautifulsite.net/blog/2011/11/detecting-mobile-devices-with-javascript/
<script>
var isMobile = {
Android: function() {
return navigator.userAgent.match(/Android/i);
},
BlackBerry: function() {
return navigator.userAgent.match(/BlackBerry/i);
},
iOS: function() {
return navigator.userAgent.match(/iPhone|iPad|iPod/i);
},
Opera: function() {
return navigator.userAgent.match(/Opera Mini/i);
},
Windows: function() {
return navigator.userAgent.match(/IEMobile/i);
},
any: function() {
return (isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Opera() || isMobile.Windows());
}
};
function load()
{
var w=((screen.availWidth)/50)*49;
var h=(w/4)*3;
if( isMobile.any() ){
var t=w;
w=h;
h=t;
}
var a=document.getElementById('banner');
a.style.width=w+'px';
a.style.height=(h/4)+'px';
var b=document.getElementById('main');
b.style.width=w+'px';
b.style.height=Math.round((h/7)*4)+'px';
}
</script>