HREF ="#"重定向到索引页面,而不是当前页面的顶部 [英] href="#" redirects to the index page but not to the current page's top

查看:100
本文介绍了HREF ="#"重定向到索引页面,而不是当前页面的顶部的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在该网站有一个奇怪的问题。具有 href =#anything的链接标记不会将您移动到页面顶部或指定的锚点,它会将您移动到主页。就是这样 - 当我将鼠标悬停在链接上时,在我的FF状态栏 example.com /#而不是 example.com/testpage.php#



网站充斥着垃圾代码,无法验证所有设置,尤其是标题配置等。 b
$ b

任何提示可能在哪里?



PS Link的 href 不会被JS改变,当我点击它时,Firebug宣称它是 href =#。 / p>

解决方案

我最初的想法是,您可能有一个基地标签在某处播放。请检查您的代码是否符合以下条件,并在必要时将其删除:

 < base href =http:// www .mydomain.com / testpage.php/> 

显然,谨慎是必要的,因为可能有一些标记取决于任何预先存在的基本标记。还要确保你的href值没有像这样的前斜杠:

 < a href =/#任何东西>点击我< / a> 

因为这会转到根目录的默认首页上的#anything。


Having an odd problem at the site. Link tag having href="#anything" doesn't move you to the top of the page or to the specified anchor, it moves you to the home page. That's it - when I hover over the link I see at my FF's status bar example.com/# instead of example.com/testpage.php#.

Site is full of crap code and it's impossible to verify all of the settings and especially header configuration or etc.

Any hints on where this might be?

P.S. Link's href is not altered with JS, Firebug claims it to be href="#" when I click it.

解决方案

My initial thought is that you may have a base tag in play somewhere. Check your code for something like the following, and remove it if necessary:

<base href="http://www.mydomain.com/testpage.php" />

Obviously, caution is necessary as there may be some markup that is dependent upon any pre-existing base tags. Also make sure that your href value is not preceded with a foward slash like this:

<a href="/#anything">Click Me</a>

As this will go to #anything on the default startpage of the root directory.

这篇关于HREF =&QUOT;#&QUOT;重定向到索引页面,而不是当前页面的顶部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆