嗨,我正在尝试使用一些 javascript,JS 函数如下所示
var changing_thumbs = new Array();
function changeThumb(index, i, thumb_count, path) {
if (changing_thumbs[index]) {
if (path.indexOf('imageCount=') !== -1) {
lastIndexOfEquals = path.lastIndexOf('=');
path = path.substring(0, lastIndexOfEquals + 1);
$j('#' + index).attr('src', path + i);
}
else {
$j('#' + index).attr('src', path + '&imageCount=' + i);
}
i = i % thumb_count + 1;
changing_thumbs[index] = setTimeout("changeThumb('" + index + "', '" + i + "', '" + thumb_count + "', '" + path + "')", 600);
}
}
function startVideoPreview(index, thumb_count, path) {
changing_thumbs[index] = true;
changeThumb(index, 1, thumb_count, path);
}
function endVideoPreview(index, path) {
clearTimeout(changing_thumbs[index]);
document.getElementById(index).src = path;
}
html调用如下
<img id="3a80b9aa-8b2f-4fb9-b3b0-02b2f55bf3be" src="/Image/GetClipImg?photoID=3a80b9aa-8b2f-4fb9-b3b0-02b2f55bf3be&userID=2" alt="Test Clip Description" onmouseout="endVideoPreview('3a80b9aa-8b2f-4fb9-b3b0-02b2f55bf3be', '/Image/GetClipImg?photoID=3a80b9aa-8b2f-4fb9-b3b0-02b2f55bf3be&userID=2')" onmouseover="startVideoPreview('3a80b9aa-8b2f-4fb9-b3b0-02b2f55bf3be', 7, '/Image/GetClipImg?photoID=3a80b9aa-8b2f-4fb9-b3b0-02b2f55bf3be&userID=2')">
一切似乎都很好,但这两行
i = i % thumb_count + 1;
changing_thumbs[index] = setTimeout("changeThumb('" + index + "', '" + i + "', '" + thumb_count + "', '" + path + "')", 600);
在执行之前的 IF 语句后永远不会被击中,他们只是被踩到了。我确信这将是一些基本的东西,但我对 JS 很陌生,我似乎看不出问题出在哪里。任何提示或提示将不胜感激。