Reputation: 147
I have a simple .html page which uses Javascript to display some popups. Now If the Javascript is disabled I want to show some text with anchor links so if javascript is enabled I should be able to show the popups but if Javascript is disabled i want to display some text and popups shouldnt be displayed. I dont want to use is there a way i can do it with HTML, CSS?
Name: <a class="icon_help" href="#hbc_2" title="Prevention, Immunization & Screening">2</a><noscript><a href="" title="">2</a></noscript>
If you see the above statement there is a small icon which is displayed with Javascript but if Javascript is disabled I just want to display the text in anchor tag. But whats happening currently is when Javascript is disabled the text in anchor link is displayed along with the icon I just want the text to be displayed as Javascript is turned off. Thanks
Upvotes: 0
Views: 207
Reputation: 498
I assume your question is, "how can I show specific content if Javascript is disabled?" You can use the noscript
tag.
<noscript>
<!-- content -->
</noscript>
This will cause browsers that do not support JavaScript to simply ignore this tag, and process what's nested inside it. Browsers that support JavaScript skip this tag if JavaScript is enabled. More examples and full attribute list: http://www.w3schools.com/tags/tag_noscript.asp
I strongly suggest you do not show automatic pop-ups using JavaScript or any other implementation, though.
Upvotes: 0
Reputation: 449485
Use progressive enhancement:
<a href="/link/to/help/document.html"
onclick="do_javascript_stuff(); return false">
(It is considered good form to add the click
event to the link in the head
part of the document, or in a separate script file, but this will do fine as well.)
This way, if JavaScript is turned off, the user will be taken to the HTML document; otherwise, your JavaScript actions will fire.
Upvotes: 1
Reputation: 17084
Add a no script clause:
<noscript>
<a href="blabla1.html">Link 1</a><br />
<a href="blabla2.html">Link 2</a><br />
<a href="blabla3.html">Link 3</a>
</noscript>
More info here.
Upvotes: 3