IE只有bug...想想吧..。
当我这样做时,我得到对象不支持这个属性或方法...
$('#the-content').showAsModal({
'leftPosition': 100,
'topPosition': 200,
'centerX': true
});我像这样扩展了jQuery ...
(function ($) {
$.fn.showAsModal = function (options) {
var settings = $.extend({
'leftPosition': 0,
'topPosition': 0,
'transition': 'none',
'transitionSpeed': 500,
'zIndex': 9001,
'centerX': false,
'centerY': false
}, options || {});
return this.each(function () {
var self = $(this)
if (settings.centerY) settings.y = Math.floor((($(document).height() - self.height()) / 2);
if (settings.centerX) settings.x = Math.floor(($(document).width() - self.width()) / 2);
self.css({ 'position': 'absolute', 'top': settings.y + "px", 'left': settings.x + "px", 'z-index': settings.zIndex });
if (self.parent('.modal-container').length <= 0)
self.wrap("<div style=\"display:none;\" class=\"modal-container\"></div>");
if (self.siblings('.modal-mask').length <= 0)
self.parent().append("<div style=\"width:" + $(document).width() + "px;height:" + $(document).height() + "px;\" class=\"modal-mask\"></div>");
self.parent().show().end();
});
};
$.say = function () {
};
})(jQuery);我正在导入JQuery,然后导入一个只包含上述代码片段的文件。
这在firefox中工作得很好。
让我们开始一项倡议,阻止人们从我们的网站使用IE。如果我们都这么做..。
发布于 2010-10-23 07:14:43
你的代码中有一个语法错误,因此你的代码在任何浏览器中都不能工作。
if (settings.centerY) settings.y = Math.floor((($(document).height() - self.height()) / 2);Math.floor后面的3个括号中的一个太多了
https://stackoverflow.com/questions/4001355
复制相似问题