Reputation: 79468
What is the best way to create an alert bar with css but without javascript on the top of the page, like the one StackOverflow has for saying "Stack Overflow works best with JavaScript enabled"?
I've heard this is bad for SEO as it's duplicate content on every page. How do I prevent that?
Upvotes: 5
Views: 1626
Reputation: 623
You can try putting content that you only want users without JavaScript to see within a noscript tag.
<noscript>Please enable JavaScript.</noscript>
Upvotes: 6
Reputation: 38318
Duplicate content on every page should not affect search engine rankings as long as the content is short & simple, like a copyright notice. Stuffing your pages with too many duplicate keywords is another matter as keyword stuffing will be seen by search engines as an attempt to spam the the engine.
Upvotes: 1
Reputation: 41902
With respect to SEO, this won't count as duplicate content any more than a template header or navigation would.
Upvotes: 3
Reputation: 58999
something like this:
...
<body>
<div id="jsNotify"><p>This page works best with JavaScript</p></div>
<script type="text/javascript">
var elm = document.getElementById("jsNotify");
elm.parentNode.removeChild(elm);
</script>
...
This will add the notification at the top of the page, but will remove it if you have JavaScript enabled.
I'm not sure how you can force search engines to dismiss the text inside it. But if you have links, then you can use nofollow to stop the search engine from following the link, like so:
<a href="http://www.example.com/" rel="nofollow">limited site</a>
Upvotes: 3