Javascript IE10单击缩略图将在新窗口中打开大图像,而不是替换特征图像

Javascript IE10单击缩略图将在新窗口中打开大图像,而不是替换特征图像,javascript,internet-explorer,shopify,Javascript,Internet Explorer,Shopify,我有一个Shopify商店,当该产品有颜色变体时,它在特色图片下有缩略图。单击缩略图图像时,它将用缩略图的大版本替换特征图像。这在通常的Chrome、Firefox、Safari中非常有效,但在IE10中不起作用。在IE10中,当我单击缩略图时,它会在新窗口中打开大版本,而不是替换图像 这是我的HTML: {% if product.images.size > 1 %} <ul id="product-photo-thumbs" class="clearfix grid"

我有一个Shopify商店,当该产品有颜色变体时,它在特色图片下有缩略图。单击缩略图图像时,它将用缩略图的大版本替换特征图像。这在通常的Chrome、Firefox、Safari中非常有效,但在IE10中不起作用。在IE10中,当我单击缩略图时,它会在新窗口中打开大版本,而不是替换图像

这是我的HTML:

{% if product.images.size > 1 %}
      <ul id="product-photo-thumbs" class="clearfix grid">
        {% for image in product.images %}
        <li class="product-photo-thumb">
          <a href="{{ image.src | product_img_url: 'grande' }}">
            <img src="{{ image.src | product_img_url: 'small' }}" alt="{{ image.alt | escape }}" />
          </a>
        </li>
        {% endfor %}
      </ul>
      {% endif %}
有什么想法(除了告诉我的客户停止使用IE:p之外)?谢谢

试试这个:

// Load variant image into feature area
$('.product-photo-thumb a').click(function(e) {
    e.preventDefault();
    var url = $(this).attr('href');
    $('#product-photo-container img').attr('src',url);
});

我认为你需要两样东西,一个变量,使用
e
而不是
event
来避免关键字冲突。在实际执行操作之前,请放置默认值。

IE中的JS运行不正常,这就是为什么在单击图像时会出现默认的单击操作。我建议查看您的错误控制台(并将其设置为在页面更改时不删除自己)。。。编辑我还注意到您正在调用
event.preventDefault()
,但您没有在事件处理程序中声明
event
参数。您可以改为使用
return false
或只添加
event
作为参数。如果您有一个click事件处理程序,则不需要。那么您就不必担心事件的传播。
// Load variant image into feature area
$('.product-photo-thumb a').click(function(e) {
    e.preventDefault();
    var url = $(this).attr('href');
    $('#product-photo-container img').attr('src',url);
});