火狐和IE的JS,IE居然报错?求助了,卡了一天
(function($){
$.fn.bgIframe = $.fn.bgiframe = function(s) {
if ( $.browser.msie && /6.0/.test(navigator.userAgent) ) {
s = $.extend({
top : 'auto', // auto == .currentStyle.borderTopWidth
left : 'auto', // auto == .currentStyle.borderLeftWidth
width : 'auto', //auto == 200px;
height : 'auto', // auto == offsetHeight
opacity : true,
src : 'javascript:false;'
}, s || {});
var prop = function(n){return n&&n.constructor==Number?n+'px':n;},
html = '<iframe class="bgiframe"frameborder="0"tabindex="-1"src="'+s.src+'"'+
'style="display:block;position:absolute;z-index:-1;'+
(s.opacity !== false?'filter:Alpha(Opacity=\'0\');':'')+
'top:'+(s.top=='auto'?'expression(((parseInt(this.parentNode.currentStyle.borderTopWidth)||0)*-1)+\'px\')':prop(s.top))+';'+
'left:'+(s.left=='auto'?'expression(((parseInt(this.parentNode.currentStyle.borderLeftWidth)||0)*-1)+\'px\')':prop(s.left))+';'+
'width:'+(s.width=='auto'?'expression(this.parentNode.offsetWidth-2010+\'px\')':prop(s.width))+';'+
'height:'+(s.height=='auto'?'expression(this.parentNode.offsetHeight+\'px\')':prop(s.height))+';'+
'"/>';
return this.each(function() {
if ( $('> iframe.bgiframe', this).length == 0 )
this.insertBefore( document.createElement(html), this.firstChild );
});
}
return this;
};
})(jQuery);
jQuery.fn.selectCity = function(targetId) {
var _seft = this;
var targetId = $(targetId);
this.click(function(){
var A_top = $(this).offset().top + $(this).outerHeight(true); // 1
var A_left = $(this).offset().left;
targetId.bgiframe();
targetId.show().css({"position":"absolute","top":A_top+"px" ,"left":A_left+"px"});
});
targetId.find("#22").click(function(){
targetId.hide();
});
$(document).click(function(event){
if(event.target.id!=_seft.selector.substring(1)){
targetId.hide();
}
});
targetId.click(function(e){
e.stopPropagation(); // 2
});
return this;
}
$(function(){
$("#selecttags").selectCity("#m_tagsItem");
}); Internet?Explorer 火狐 JavaScript
[解决办法]
<script src="http://www.coding123.net/js/jquery.js"></script>
<script>
(function ($) {
$.fn.bgIframe = $.fn.bgiframe = function (s) {
if ($.browser.msie && /6.0/.test(navigator.userAgent)) {
s = $.extend({
top: 'auto', // auto == .currentStyle.borderTopWidth
left: 'auto', // auto == .currentStyle.borderLeftWidth
width: 'auto', //auto == 200px;
height: 'auto', // auto == offsetHeight
opacity: true,
src: 'javascript:false;'
}, s
[解决办法]
{});
var prop = function (n) { return n && n.constructor == Number ? n + 'px' : n; },
html = '<iframe class="bgiframe"frameborder="0"tabindex="-1"src="' + s.src + '"' +
'style="display:block;position:absolute;z-index:-1;' +
(s.opacity !== false ? 'filter:Alpha(Opacity=\'0\');' : '') +
'top:' + (s.top == 'auto' ? 'expression(((parseInt(this.parentNode.currentStyle.borderTopWidth)
[解决办法]
0)*-1)+\'px\')' : prop(s.top)) + ';' +
'left:' + (s.left == 'auto' ? 'expression(((parseInt(this.parentNode.currentStyle.borderLeftWidth)
[解决办法]
0)*-1)+\'px\')' : prop(s.left)) + ';' +
'width:' + (s.width == 'auto' ? 'expression(this.parentNode.offsetWidth-2010+\'px\')' : prop(s.width)) + ';' +
'height:' + (s.height == 'auto' ? 'expression(this.parentNode.offsetHeight+\'px\')' : prop(s.height)) + ';' +
'"/>';
return this.each(function () {
if ($('> iframe.bgiframe', this).length == 0)
this.insertBefore(document.createElement(html), this.firstChild);
});
}
return this;
};
})(jQuery);
jQuery.fn.selectCity = function (targetId) {
var _seft = this;
var targetId = $(targetId);
this.click(function () {
var A_top = $(this).offset().top + $(this).outerHeight(true); // 1
var A_left = $(this).offset().left;
targetId.bgiframe();
targetId.show().css({ "position": "absolute", "top": A_top + "px", "left": A_left + "px" });
});
targetId.find("#22").click(function () {
targetId.hide();
});
$(document).click(function (event) {//alert(_seft[0].id)
if (event.target.id != _seft.selector.substring(1)) {
targetId.hide();
}
});
targetId.click(function (e) {
e.stopPropagation(); // 2
});
return this;
}
$(function () {
$("#selecttags").selectCity("#m_tagsItem");
});
</script>
<input type="text" id="selecttags" />
<div style="display:none;position:absolute;" id="m_tagsItem"><div>item1</div><div>item1</div><div>item1</div><div>item1</div></div>
$(document).click(function (event) {
alert(_seft)//
alert(_seft.selector)//
if (event.target.id != _seft.selector.substring(1)) {
targetId.hide();
}
});