开发者

What is the best way to link to domain root?

开发者 https://www.devze.com 2023-02-22 00:13 出处:网络
I\'m setting up links and not sure which is the best way to link to the domain root should I do <a href=\"/\">home</a> or <a href=\"http://example.com\">home</a> ?

I'm setting up links and not sure which is the best way to link to the domain root should I do

<a href="/">home</a> or <a href="http://example.com">home</a> ?

is th开发者_JAVA技巧ere a cooler way that I'm unaware of?


Unless you have a specific reason you want to always use HTTP, use <a href="/">text</a>. You'll run into problems with SSL otherwise.

There is a cooler way to do it if you're loading scripts, and that is to load cross domain scripts in a protocol-neutral way, as such:

<script src="//example-cdn.com/scripts/jquery-latest-min.js"></script>

That way you avoid the HTTP mixed content warnings in IE.


the simpler / variant is portable across domains, might be considered as an advantage.


depends on the programming language you are using.. and the web-framework.. in plain html / would be your choice (portability)

0

精彩评论

暂无评论...
验证码 换一张
取 消