如何在 HTML HREF 中组合锚标记和传递的变量?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10158283/
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 23:48:29  来源:igfitidea点击:

How do I combine an anchor tag AND a passed variable in an HTML HREF?

htmlanchorhref

提问by Fredashay

Say I have an anchor somewhere on a different page:

假设我在不同页面的某处有一个锚点:

<A NAME="blah">

On the page I'm currently on, I want to go that that anchor on that different page while also passing a GET parameter, such as, for example:

在我当前所在的页面上,我想在该不同页面上使用该锚点,同时还传递一个 GET 参数,例如:

<A HREF="otherpage.htm#blah?data=1234">Good Stuff!</A>

This doesn't seem to be working for me. It loads the page and passes the variable but doesn't go to the anchor. I've searched for examples on the anchor tag, and there's tons of them, but nobody talks about jumping to an anchor in a page while also passing parameters in the URL.

这似乎对我不起作用。它加载页面并传递变量但不转到锚点。我搜索了锚标记上的示例,其中有很多示例,但没有人谈论跳转到页面中的锚点同时还传递 URL 中的参数。

回答by Randy the Dev

The bookmark always goes last.

书签总是放在最后。

<A HREF="otherpage.htm?data=1234#blah">Good Stuff!</A>