Html 如何使链接仅出现在某些页面中

Html 如何使链接仅出现在某些页面中,html,css,Html,Css,我想一个链接出现在博客上的任何地方,除了主页 然而,我只希望链接在主页上不起作用,我仍然希望你的页面上有这个词,只是没有链接 <center> <div id='customheader'> <a href='http://www.yourpage.com/'>YOUR PAGE</a> </div> </center> 使用javascript: if (document.URL == '

我想一个链接出现在博客上的任何地方,除了主页

然而,我只希望链接在主页上不起作用,我仍然希望你的页面上有
这个词,只是没有链接

<center>
    <div id='customheader'>
       <a href='http://www.yourpage.com/'>YOUR PAGE</a>
    </div>
</center>

使用javascript:

if (document.URL == 'http://www.yourpage.com/') {
    document.getElementById('customheader').insertAdjacentHTML('afterbegin', 'Your page');
} else {
    document.getElementById('customheader').insertAdjacentHTML('afterbegin', '<a href="http://www.yourpage.com">Your page</a>');  
}
if(document.URL=='http://www.yourpage.com/') {
document.getElementById('customheader')。insertAdjacentHTML('afterbegin','YourPage');
}否则{
document.getElementById('customheader').insertAdjacentHTML('afterbegin','';
}
使用PHP:

<div id='customheader'>
<?php
  if ($_SERVER['REQUEST_URI'] == '/' || $_SERVER['REQUEST_URI'] == "/index.php") {
    echo "YOUR PAGE";
  } else {
    echo "<a href='http://www.yourpage.com/'>YOUR PAGE</a>";
  }
?>
</div>

通过CSS

<style type="text/css">
    body #customheader a[href]:after { content: ''; }
</style>

正文#customheader a[href]:在{content:'';}之后

但是你需要让它只出现在主页上。它在较旧的浏览器上也不起作用。

您使用的服务器端应用程序是什么?您需要使用脚本语言。无论是在浏览器(JavaScript)上还是在服务器上。stackoverflow上已经有大量答案可能重复,而且中间的标签也会贬值。