Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Alert Bar on Top of HTML Page?

Tags:

html

seo

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?

like image 588
Lance Avatar asked Dec 13 '09 06:12

Lance


People also ask

How do I make an alert pop up in HTML?

The Window alert() method is used to display an alert box. It displays a specified message along with an OK button and is generally used to make sure that the information comes through the user. It returns a string which represents the text to display in the alert box.

How do you style an alert box?

The standard alert box in JavaScript does not provide the option to apply CSS. To style your alert box, you need to create a custom one first. The custom alert box will be created using jQuery and styles will be applied to CSS.

What is a CSS alert?

Primer CSS Alerts Color is used to add colors to the alerts like blue, red, green and yellow. Classes: flash: This is the default class, it provides blue color to the alert. flash-warn: This class provides yellow color to the alert. flash-error: This class provides red color to the alert.


2 Answers

You can try putting content that you only want users without JavaScript to see within a noscript tag.

<noscript>Please enable JavaScript.</noscript>
like image 96
CPrimer Avatar answered Sep 24 '22 19:09

CPrimer


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>
like image 20
Marius Avatar answered Sep 24 '22 19:09

Marius