私は自分のソフトウェアを操作するためにjQueryファイルをたくさん書いていました。私のソフトウェアはうまく設計されていないので、jQueryを使ってソフトウェアをより良くすることに決めました。 jQueryはIE6-8を除くすべてのブラウザで動作します。サポートされていないブラウザにはフォールバックがありますが、IE6-8はトラフィックの25%を補うものです。私はその25%に他のユーザーと同じエクスペリエンスを提供したいと考えています(IE8は約21%です。約、IE6 & IE7私は気にしない)。そのスクリプトの半分の動作についてjQueryの問題
$(document).ready(function(){
$('input#v65-product-wishlist-button').replaceWith('<input type="submit" id="v65-product-wishlist-button" class="graybutton" name="btnaddtowishlist" alt="Add to Wishlist" value="Add to Wishlist" title="Add this item to my Wishlist">');
$('td[background="v/vspfiles/templates/volusion/images/expand_tab_right.gif"]').remove();
$('td[background="v/vspfiles/templates/volusion/images/expand_tab_left.gif"]').remove();
$('td[background="v/vspfiles/templates/volusion/images/PBox_Opt_Back.gif"]').remove();
$('td[background^="v/vspfiles/templates/volusion/images/PBox_Border_"]').remove();
$('td img[src^="v/vspfiles/templates/volusion/images/PBox_Border_"]').parent().remove();
$('td[background^="v/vspfiles/templates/volusion/images/DBox_Border_"]').remove();
$('td img[src^="v/vspfiles/templates/volusion/images/DBox_Border_"]').parent().remove();
$('td img[src="v/vspfiles/templates/volusion/images/RBox_Border_Left_Top.gif"]').parent().closest("table").addClass('ReviewBox');
$('td img[src="v/vspfiles/templates/volusion/images/RBox_Border_Left_Top.gif"]').parent().remove();
$('input.vCSS_input_addtocart').after('<input type="submit" class="vCSS_input_addtocart blackbutton" name="btnaddtocart" alt="Add to Cart" value="Add to Cart" title="Add this item to my Cart">').remove();
$('img.vCSS_img_email_a_friend').replaceWith('<span id="graybutton">Email a Friend</span>');
$('img.vCSS_img_larger_photo').replaceWith('<span id="graybutton">Larger View</span>');
$('img.vCSS_img_history_off').replaceWith('<span id="blackbutton">Turn History Off</span>');
$('img.vCSS_img_history_clear').replaceWith('<span id="graybutton" class="mediumbutton">Remove</span>');
$("td#Header_ProductDetail_ProductDetails, td#Header_ProductDetail_TechSpecs, td#Header_ProductDetail_ExtInfo").removeAttr("background");
$('#Header_ProductDetail_ProductDetails').siblings("td[width='90%']").remove();
$('img.vCSS_img_icon_free_shipping').replaceWith('<span class="freeshipping">This item qualifies for Free Shipping!</span>');
$('img[src="v/vspfiles/templates/volusion/images/buttons/btn_reviews_yes.gif"]').replaceWith('<span id="graybutton" class="smallbutton">Yes</span>');
$('img[src="v/vspfiles/templates/volusion/images/buttons/btn_reviews_no.gif"]').replaceWith('<span id="graybutton" class="smallbutton">No</span>');
$('img[src="v/vspfiles/templates/volusion/images/Icon_Help_Options.gif"]').replaceWith('<span class="optionshelp"><sup>?</sup></span>');
$('img.vCSS_img_line_group_features').remove();
$('img.vCSS_img_heading_history').after('<span class="title">Recently Viewed</span>').remove();
$("td").filter(function() { return $(this).html() === ' '; }).remove();
$('table.ReviewBox tbody tr td table tbody tr td i:contains("By:")').each(function(){
$(this).html($(this).html().split("By:").join(""));
});
$('input[type="checkbox"], input[type="radio"]').after("<span />");
$(function() {
if ($("div#ProductDetail_ProductDetails_div2 table tbody tr").text().trim() == '') {
$("div#ProductDetail_ProductDetails_div2").css("border", "0px");
$("div#ProductDetail_ProductDetails_div").css({'border-bottom-left-radius' : '5px', '-moz-border-bottom-left-radius' : '5px', '-webkit-border-bottom-left-radius' : '5px', 'border-bottom-right-radius' : '5px', '-moz-border-bottom-right-radius' : '5px', '-webkit-border-bottom-right-radius' : '5px'});
}
});
});
:だからここに私のコードのいくつかの例を示します(これは、すべての非常に基本的ですが、私は次のようになり、約10のファイルを持っています)。いくつかのremove関数とreplace関数のいくつかは正常に動作します。しかし、そのほとんどはそうではありません。
jsFiddleでこれをテストしようとしました。 IE8では動作しますがIE6では動作しません& IE7、これは完璧です。なぜ私のサイトではうまくいかないのか分かりません。 JavaScriptがインラインであるか、ファイル内で呼び出された場合に違いがありますか?現在、すべてのJSが<head>
タグの間のファイルから呼び出されています。私はjQuery以外のものを移動したり変更したりすることができます。 jQueryを更新することはできませんし、jQueryを再配置することもできません。何が私をさらに邪魔してくれるの?それは、同じファイルと同じjQueryを使っている私の他のサーバー上で、それは動作します!しかし、それは私を助けない、私はこのサーバーで動作する必要があります。ブラウザのキャッシュをクリアする方法
キャッシュをクリアしましたか? – Evan
この反IE暴言は役に立たない。 IEのデバッグコンソールで見てみましたか? –
jsfiddle.net – gotofritz