HTML link to itself with GET
I want to create a number of links within a page that have different GET parameters. However, I want the page that is called to be the current page.
<a href="ITSELF?param1=123¶m2=345">Link1</a>
<a hre开发者_Python百科f="ITSELF?param1=234¶m2=345">Link2</a>
Where "ITSELF" is the page currently loaded. I'd rather not include a hard link to a specific page location as this PHP can potentially be loaded from different URLs.
Suggestions?
-Jonathan
Just don't put the ITSELF in there and it will do what you want, e.g.
<a href="?param1=123¶m2=345">Link1</a>
Note that this will only include the path, not the query params, so if your current script is at /foo/bar?a=b
, the link referred to will be /foo/bar?param1=123¶m2=345
. If you want to include the a=b
as well, you'll need to figure it out server side.
精彩评论