jQuery 플러그인 용 템플릿을 사용하고 있으며 불행히도 IE8 및 IE 호환 모드에서는 작동하지 않습니다.내 jQuery 플러그인이 IE8과 완전히 호환되지 않습니까?
필자가 작성한 방식이 전혀 호환되지 않거나 방금 누락 된 것이 있는지 확실하지 않습니다.
HTML :
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>SuperHero Demo</title>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript" src="Scripts/SuperSelect.js"></script>
</head>
<body>
<div class="test" style="border:1px solid #000;">
<p>Hello World!</p>
</div>
<div>
<p>Sup World</p>
</div>
<script>
$('.test').superHero({
});
</script>
</body>
</html>
SCRIPT :
// Utility
if (typeof Object.create !== 'function') {
Object.create = function(obj) {
function F(){};
F.prototype = obj;
return new F();
};
}
(function($, window, document, undefined) {
var Super = {
init: function(options, elem) {
var self = this;
self.elem = elem;
self.$elem = $(elem);
if (typeof options === 'string') {
self.duration = options;
} else {
// object was passed
self.duration = options.duration;
}
self.options = $.extend({}, $.fn.superHero.options, options);
self.replaceSelect();
},
replaceSelect: function(duration) {
var self = this;
$('.test').hide();
$('.test').after('<select><option value="volvo">Volvo</option><option value="saab">Saab</option><option value="mercedes">Mercedes</option><option value="audi">Audi</option></select>');
},
};
$.fn.superHero = function(options){
return this.each(function() {
var hero = Object.create(Super);
hero.init(options, this);
$.data(this, 'superHero', hero);
});
};
$.fn.superHero.options = {
duration: 5000, //Milliseconds that each slide remains on screen. Default is 5 seconds.
transition: 'fade', //How will the slides trascend?
};
})(jQuery, window, document);
http://jsfiddle.net/userdude/QWhPL/1/
가 나는 그것이 "작동하지 않습니다"무엇의 많은 설명과 함께 라인 (12)의 말을, 선 (12)있을거야 ';)' –
당신은 다음과 같이 말합니다 : init : function (options, elem) {? –
나는 당신이 우리에게 "일하지 않을 것"이 의미하는 바가 무엇인지, 심지어 "일할 것"이 무엇인지 짐작하기 위해 남겨 두었던 사실을 언급하고 있습니다. –