私のページhttp://www.dynamicdrive.com/dynamicindex4/imagemagnify.htmで Dynamic Drive Jquery 画像拡大鏡を使用しています。
ページを 2 つの別々のドメインにロードしました。HTML は同一で、すべてのリンク (css/js/images) はテスト サーバーへの完全な http 文字列です。ヘッダーは次のようになります。
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript" src="http://slim.bobpitch.com/DS/js/jquery.magnifier.js">
ただし、あるドメインではページは完全に読み込まれますが、jquery は機能しません。別のドメインでは jquery は機能しますが、ページの書式設定が破損しています。最初のページで表示されるエラーは次のとおりです。
Uncaught TypeError: Cannot call method 'magnify' of undefined
これは、スクリプトのこの部分を指します:
jQuery.fn.imageMagnify=function(options){
var $=jQuery
return this.each(function(){ //return jQuery obj
var $imgref=$(this)
if (this.tagName!="IMG")
return true //skip to next matched element
if (parseInt($imgref.css('width'))>0 && parseInt($imgref.css('height'))>0 || options.thumbdimensions){ //if image has explicit width/height attrs defined
jQuery.imageMagnify.magnify($, $imgref, options)
}
else if (this.complete){ //account for IE not firing image.onload
jQuery.imageMagnify.magnify($, $imgref, options)
}
else{
$(this).bind('load', function(){
jQuery.imageMagnify.magnify($, $imgref, options)
})
}
})
私は完全に当惑しており、熱狂的な CSS のいじり屋でしかありません。私がJava JavaScript について知っていることは、非常に小さなことの裏に書かれている可能性があります。あるドメインでは機能するのに、他のドメインでは機能しないのはなぜですか?