【问题标题】:jQuery not working in Safari/Chrome with AJAX control on the pagejQuery 在 Safari/Chrome 中无法在页面上使用 AJAX 控件运行
【发布时间】: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

标签: jquery asp.net


【解决方案1】:

我认为您遇到了一个已知的兼容性错误 - 请查看此资源以解决问题!

http://blog.turlov.com/2009/01/aspnet-ajax-compatibility-patch-for.html

【讨论】:

    猜你喜欢
    • 2022-01-07
    • 1970-01-01
    • 1970-01-01
    • 2013-07-08
    • 2011-12-23
    • 2016-08-11
    • 1970-01-01
    • 1970-01-01
    • 2018-02-04
    相关资源
    最近更新 更多