您好我想这取决于网站网址的子域切换样式如何根据子域设置Javascript中的样式表?
伪例如:
if variationA.mysite.com then
Use stylesheetA.css
else If variationB.mysite.com then
Use stylesheetB.css
else
Use stylesheetC.css
end if
您好我想这取决于网站网址的子域切换样式如何根据子域设置Javascript中的样式表?
伪例如:
if variationA.mysite.com then
Use stylesheetA.css
else If variationB.mysite.com then
Use stylesheetB.css
else
Use stylesheetC.css
end if
你可以使用JavaScript做这个客户端上的是这样的:
var subDomain = window.location.host.split('.')[0]; //pull the subdomain from the host
var cssUrl = 'stylesheetC.css';
if (subDomain == 'variationA') cssUrl = 'stylesheetA.css';
else if (subDomain == 'variationB') cssUrl = 'stylesheetB.css';
$('head').append("<link rel='stylesheet' href='"+cssUrl+"'>");
但是,如果可能的话,做这个服务器端会更有意义。
太棒了,会给你一个尝试谢谢 – 2014-11-24 09:37:08
太棒了!如果这是有帮助的,你能否将我的答案标记为已接受,这样这个问题就会显示出来,正如任何其他人寻找答案一样? http://i.stack.imgur.com/uqJeW.png – 2014-11-24 14:06:40
您使用的是服务器端语言,还是仅仅是一个HTML页面? – 2014-11-24 02:33:03
嗨,只是HTML Casey – 2014-11-24 02:34:46