【发布时间】:2012-03-15 05:28:59
【问题描述】:
我将此代码用于一个简单网站的不同页面上的水平和垂直滑块控件。它适用于 IE 和 Firefox 中的所有页面;但在 Safari 和 Chrome 的一页上,它失败了。该页面有一个 AJAX 控件(Facebook 共享的弹出窗口)。当我移除脚本管理器和 AJAX 控件后,jQuery 脚本完美执行。
如何修复此脚本,以便在页面上使用 AJAX 控件执行?
这是脚本:
<script>
var over = false;
var intervalID = 0;
$("#btn_Right").hover(
function() {
over = true;
DoMove("Left");
},
function() {
over = false;
clearInterval(intervalID);
}
);
$("#btn_Left").hover(
function() {
over = true;
DoMove("Right");
},
function() {
over = false;
clearInterval(intervalID);
}
);
function DoMove(direction) {
var interval = 600;
intervalID = setInterval(function() {
if (over)
MoveFrames(direction);
}, interval);
}
function MoveFrames(direction) {
var itemWidth = 175;
var viewFrameWidth = parseInt(document.getElementById('ViewFrame').style.width);
var containerWidth = parseInt(document.getElementById('Container').style.width);
var CurrentPos = parseInt(document.getElementById('Container').style.marginLeft);
if (CurrentPos % itemWidth == 0) {
if ((direction == "Left" && CurrentPos <= -(containerWidth - viewFrameWidth)) || (direction == "Right" && CurrentPos >= 0)) {
clearInterval(intervalID);
}
else {
if (direction == "Left") {
$("#Container").animate({ marginLeft: '-=175' }, 400);
}
else if (direction == "Right") {
$("#Container").animate({ marginLeft: '+=175' }, 400);
}
}
}
}
【问题讨论】:
-
我忘了补充说脚本一直执行到动画代码,但是什么也没发生...
-
脚本管理器和 ajax 控件的 id 是什么?
-
ScriptManager1...会有问题吗??
-
ajax弹出控件是ModalPopupExtender1。触发 ajax 弹窗的按钮 ID 是 imageButton_Connect、lbn_ShareUpper。
-
可能是冲突错误。试试不冲突的 jQuery