サイトに新しいスライドショーを取り入れようとしています。スライドショーには、"height = "80%"" のオプションを除いて、必要なものがすべて含まれています。つまり、新しいサイトのデザインは Android アプリケーションのように分類されるため、スライドショーをブラウザーに合わせてスケーリングする必要があります。完全に没入型。
スライドショー自体にはこのオプションがないため、ドキュメント/ブラウザ ウィンドウのサイズを 2 秒ごとにチェックし、常に画面に収まるようにスライドショー自体をリロード/サイズ変更する JavaScript コードを作成しています。しかし、問題は、特定のコード文字列をスクリプトに貼り付けた後、javascript がオンロードで 1 回しか実行されず、「setTimeout」を呼び出さないことです。
したがって、問題は setTimeout が実際に動作を停止することです。そのため、次のコード文字列を含めた後、以前は動作していました。
var thescript = document.createElement("script");
thescript.type = "text/javascript";
thescript.innerHTML="jQuery.flashgallery('gallery/ArtGallery.swf', 'gallery/gallery.xml', {width: '100%', height: '"+calcheight+"px', background: '#000000'});";
document.getElementById('galleryid').appendChild(thescript);
完全な JavaScript チェック関数は次のとおりです。
function getDocSpecs() {
clearTimeout(t);
var D = Math.max(
Math.max(document.body.scrollHeight, document.documentElement.scrollHeight),
Math.max(document.body.offsetHeight, document.documentElement.offsetHeight),
Math.max(document.body.clientHeight, document.documentElement.clientHeight));
var Le = Math.max(
Math.max(document.body.scrollWidth, document.documentElement.scrollWidth),
Math.max(document.body.offsetWidth, document.documentElement.offsetWidth),
Math.max(document.body.clientWidth, document.documentElement.clientWidth));
calcheight = (0.80 * D);
alert(preheight + "_" + prewidth + "_" + D + "_" + Le + "_");
if (preheight != D || prewidth != Le) {
var thescript = document.createElement("script");
thescript.type = "text/javascript";
thescript.innerHTML = "jQuery.flashgallery('gallery/ArtGallery.swf', 'gallery/gallery.xml', {width: '100%', height: '" + calcheight + "px', background: '#000000'});";
document.getElementById('galleryid').appendChild(thescript);
}
preheight = D;
prewidth = Le;
t = setTimeout('getDocSpecs()', 2000);
}
これらの 2 つは互いに気に入らないようです。
var thescript = document.createElement("script");
thescript.type = "text/javascript";
thescript.innerHTML="jQuery.flashgallery('gallery/ArtGallery.swf', 'gallery/gallery.xml', {width: '100%', height: '"+calcheight+"px', background: '#000000'});";
document.getElementById('galleryid').appendChild(thescript);
と
t = setTimeout('getDocSpecs()', 2000);
最初にスライドショーをロードしてから関数を呼び出し、クリックでアクティブ化されたテキストを追加し、複数の関数を呼び出すなどして、それをだまそうとしました.