【发布时间】:2014-07-28 13:24:40
【问题描述】:
我尝试过搜索,但没有找到任何作品。该站点不适用于 php,我知道如何使用 php,但我需要任何其他方式。
我只想要一个简单的 IF THEN 语句来说明如果网站是 www.a.com 那么“这个样式表”“这个页面标题”“这个标志”等等。我将通过页面多次使用 if 函数.如果站点是 a.com,则此图像,此文本等。如果是 b.com,则一切都不同。
我还希望它只识别域本身,所以如果在 a.com/thispage.html 上,它仍然会加载正确的数据。
原因是,我有两个站点指向同一个文件夹,即商店、相同产品等。但是我们将产品作为“a”和“b”进行营销。所以我只想查看用户在哪个站点上并获取有关该站点的正确信息。
这是我想出的,但没有生成所需的html。
<script>
window.onload = function ()
var element = document.getElementbyId('idElement');
if (location.href == "a.com")
{
<link href="/landing.css" rel="stylesheet" type="text/css" />
}
if (location.href == "b.com")
{
<link href="/landing2.css" rel="stylesheet" type="text/css" />
}
</script>
<script>
if (location.href == "a.com")
{
<title>AAAAAAAAAAAAA</title>
}
if (location.href == "b.com")
{
<title>BBBBBBBBBBBBB</title>
}
</script>
<script>
if (location.href == "a.com")
{
<img src="a.png">
}
if (location.href == "b.com")
{
<img src="b.png">
}
</script>
等等等等等等
【问题讨论】:
-
@Jan 不,它可能会被问得很糟糕,但它不会太宽泛,这是肯定的。
标签: javascript jquery html