link / href不会滚动到页面顶部 [英] link/href that will not scroll to the top of the page

查看:62
本文介绍了link / href不会滚动到页面顶部的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的,简单的问题,可能的简单答案。

我有< a href ="#" onclick =" javascript">点击我< / a>

所以基本上我想要一个锚点做一些javascript wen点击它,我的问题是,每当按下这个链接,因为哈希(#)页面滚动到顶部。如何使链接在html中不做任何事情(即将页面位置保持原样)而不滚动到页面顶部。


谢谢。 Josh

Okay, simple problem, probrabable simple answer.
I have <a href="#" onclick="javascript">Click Me</a>
So basicly I want an anchor to do some javascript wen its clicked, my problem is, whenever this link is pressed, because of the hash(#) the page is scrolled to the top. How can I make a link do nothing in html (ie leave the page position where it is) without it scrolling to the top of the page.

Thanks. Josh

推荐答案

只需关闭href,或删除哈希值。
Just leave the href off, or remove the hash.


哇,简单,我可怜的试试了哈哈谢谢。我想我必须离开href或者我得到验证错误。


编辑那些为我工作的neitehr

href =""当实际页面是domain.com/?p=news

并且href的删除不是xhtml complient
wow that simpl, I probrably shud have tried that lol, thanks. I think i have to leave the href on or I get validation errors.

Edit yeh neitehr of those work for me as
href="" sends the user back to domain.com when the actual page is domain.com/?p=news
and the removal of the href is not xhtml complient


时,将用户发送回domain.com

哇,简单,我可怜地试试了哈哈,谢谢。我想我必须离开href或者我得到验证错误。


编辑那些为我工作的neitehr

href =""当实际页面是domain.com/?p=news

并且href的删除不是xhtml complient
wow that simpl, I probrably shud have tried that lol, thanks. I think i have to leave the href on or I get validation errors.

Edit yeh neitehr of those work for me as
href="" sends the user back to domain.com when the actual page is domain.com/?p=news
and the removal of the href is not xhtml complient

$ b $时,将用户发送回domain.com b
为什么不使用< span onclick = ..> ?或者这是无效的?

Why not use like <span onclick=..> ? Or is that not valid?


这篇关于link / href不会滚动到页面顶部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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