views:

63

answers:

4

Hi All,

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

+3  A: 

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.

Gert G
Not really good for what the OP needs IMO (even though he asked for it). I think what is needed here is progressive enhancement.
Pekka
A: 

Have javascript to hide the box that contains those links?

baloo
A: 

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.

Propeng
+1  A: 

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.

Pekka
is there a way to do it staying on the same page?
kjkjl
i mean if JS is off just display HTML/CSS text else if JS is on display icons [Javascript]
kjkjl
@kjkj it's possible but complicated - in that case, you may be easier off with noscript tags!
Pekka