Я пытаюсь включить новое слайд-шоу на свой сайт. В слайд-шоу есть все, что мне нужно, кроме опции «height =« 80% »», то есть я хочу, чтобы слайд-шоу масштабировалось с помощью браузера, потому что новый дизайн сайта будет сортироваться, как приложение для Android; полностью погружен.javascript setTimeout перестает работать после включения createElement
Поскольку у этого слайд-шоу эта опция отсутствует, я создаю код javascript, который проверяет размер окна документа/браузера каждые 2 секунды и перезагружает/изменяет размер самого слайд-шоу, чтобы он всегда соответствовал экрану. Но проблема в том, что javascript будет запускаться только один раз, загружать и не вызывать «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);
}
Эти два, кажется, не похожи друг на друга:
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);
Я пытался обмануть его, загрузив слайд-шоу первый затем вызвать функцию, добавив клик активированного текста с, вызывая множество функций и т.д.
Почему, по-вашему, вам нужно создать элемент '