简体   繁体   中英

how can I make a <a> tag so that when I click that <a> tag,the URL should not go in the address bar?

In My JSP ,I have an <a href="patient/tools.do?Id=<%=mp.get("FROM_RANGE") %>"> <%= mp.get("DESCRITPION") %></a> ....when i click the anchor tag the url normally goes in the Address bar.I want the URL not to go in the Address bar.how can i do that?

Please note that <%=mp.get("FROM_RANGE") %> and <%= mp.get("DESCRITPION") %> are all scriptlets for getting value from java variables...

Thanks in advance!

You cannot. (Why do you need to do it anyway?)

But you could open the link via AJAX - but then you'd need to process the returned data via JavaScript. Or you could use frames. They are horrible and annoying for users though.

Investigate .htaccess and URL rewrites. I do not believe you can change the not change the url in an <a> tag. An example also of using javascript to change the url is in a game(mentioned on slashdot) that is played entirely in the url bar. http://probablyinteractive.com/url-hunter . Check out the source code and mabye you could derive something from that.

You have some options to do this:

  1. Wrap your contents in a frameset or iFrame.
  2. Load your contents dynamically using AJAX.
  3. If you have a control over the domain name, then you can use domain masking technique

you can just use IFrame and change URL for that iframe. Make iframe as big as the page itself.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM