Html <a href=" "> 不工作

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20724590/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-28 22:35:06  来源:igfitidea点击:

<a href=" "> not working

htmlbrowseranchorhref

提问by progit

The following hyperlink does not work, though it works when you click open in new tab button.

以下超链接不起作用,但当您单击在新选项卡中打开按钮时它起作用。

<div class="span12 category-products" style="margin: 0 auto;">
<div class="toolbar">
    <div class="row big_with_description" style="position:relative;">                                                                   
        <a href="http://www.grewal.nl/reviveme/repair/mobile.html">
            <div class="span5 product hover">
                <img src="http://www.grewal.nl/reviveme/media/catalog/category/mobile2.jpg" class="category-thumbnail product-retina" width="499" height="268" alt="Mobile">    
            </div>
        </a>
    </div>
</div>

I have tried using Chrome and Firefox. The live page can be seen here.

我尝试过使用 Chrome 和 Firefox。可以在此处查看实时页面。

回答by Kaloyan

If you disable JavaScript the link works. In ajaxtoolbar.js you have the following code:

如果您禁用 JavaScript,则链接有效。在 ajaxtoolbar.js 中有以下代码:

$jq('a','.toolbar').click(function(event) {
    link    =   $jq(this).attr('href');

    if((link.search("mode=")!=-1||link.search("dir=")!=-1||link.search("price=")!=-1||link.search("p=")!=-1)&&(toolbarsend==false)){
        event.preventDefault();
        ajaxtoolbar.onSend(link,'get');
    }

    return false;

});

The return false;prevents the link from triggering.

所述return false;防止触发的链接。

回答by ztirom

Like @Benjamin Gruenbaum said, try this:

就像@Benjamin Gruenbaum 说的,试试这个:

<div class="span12 category-products" style="margin: 0 auto;">
  <div class="toolbar">
    <div class="row big_with_description" style="position:relative;">
      <div class="span5 product hover">                                         
        <a href="http://www.grewal.nl/reviveme/repair/mobile.html">
         <img src="http://www.grewal.nl/reviveme/media/catalog/category/mobile2.jpg" class="category-thumbnail product-retina" width="499" height="268" alt="Mobile">
        </a>
      </div>
    </div>
  </div>
</div>

If it was your intention to link with this div, I would like to refer to this post: "Make a div into a link"

如果你打算与这个div链接,我想参考这篇文章:“把一个div变成一个链接