简体   繁体   中英

How to Add an HREF using Javascript?

I have an ASP.NET 4.0 site that has links to another ASP.NET site (different domain name). In situations where users from domain 1 are directed to a page on domain 2, how would I setup a Javascript routine to create an href back to domain 1? That is, I don't want to place a solid <a> tag on domain 2 pointing back to domain 1. Rather, I need a little bit of script magic that only makes the href available to users coming from domain 1. Can anyone suggest a specific Javascript library/widget that functions in this manner?

Do you have to do this in javascript? You can use the Request.UrlReferrer in the asp.net page to see where the request came from and using that you can make the link.

Uri LastUrl = Request.UrlReferrer;

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