kjkjl
kjkjl

Reputation: 147

Javascript disabled help

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 &amp; 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

Answers (4)

Propeng
Propeng

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

Pekka
Pekka

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

baloo
baloo

Reputation: 7775

Have javascript to hide the box that contains those links?

Upvotes: 0

Gert Grenander
Gert Grenander

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

Related Questions