HTML <a> tag changes url but doesn&#39;t move browser location

时间:2015-08-10 20:52:57

标签: javascript html angularjs

I'm working on a web development project using AngularJS and PHP. I have this line of seemingly trivial HTML:

<p><a href="products.php">Back to All Products</a></p>

This link is within the file products.php and appears only when a query string is present, which causes Angular and PHP to load products by category.

For some reason when I click the link it creates, the URL of the page changes but the page doesn't load, and the page content doesn't change. Even more bizarre, when I click the browser's reload button, it loads products.php. But the strangest part is that there's another link on the page that has the same link, and functions properly!

Providing an absolute link rather than relative fixes the problem, but does anyone have some idea why this would be happening?

1 个答案:

答案 0 :(得分:3)

我也遇到了这个问题,解决方法是添加target属性值_self

<p><a href="products.php" target="_self">Back to All Products</a></p>