简体   繁体   English

在Javascript中生成html链接

[英]Generating html link in Javascript

I have a simple javascript question (I'm not a javascript expert, so excuse me for this simple question ;). 我有一个简单的JavaScript问题(我不是一个JavaScript专家,所以请原谅我这个简单的问题;)。 We are currently migrating a system and on the old system there should be a simple HTML-link which directs you to the new system (with the same path). 我们目前正在迁移一个系统,在旧系统上应该有一个简单的HTML链接,它将您引导到新系统(具有相同的路径)。 My current approach doesn't not work really well: 我目前的方法并不是很好用:

Information can be found<a href="javascript:'('http://theNewServername:8080/'+(window.location.pathname));">here </a>

This doesn't represent me the right href-link. 这并不代表我正确的href-link。 Can you help me with this 'one-liner'? 你能帮我解决这个'单线'吗?

像这样?

<a href="javascript:void(window.location.href='http://theNewServername:8080/'+(window.location.hostname))">here </a>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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