Forum Moderators: open

Message Too Old, No Replies

how-to show only contents of <noscript> and hide the rest

         

krko

10:50 am on Aug 26, 2007 (gmt 0)

10+ Year Member



Hello all,

I have a simple page with javascript. All I want to do is show the contents of <noscript> in case javascript is disabled but hide all other contents as well.

For example:
<div id="whatever">some content here</div>
<div id="whatever2">some other content requiring javascript here</div>
<div id="whatever3">some more content here</div>
<noscript>some content here</noscript>

What I want:
if no javascript hide all divs and of course display the noscript

How do I do it?

Thank you,
krko

daveVk

1:35 pm on Aug 26, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



A css statement along the line of

div {display:none}

or more selective if noscript also contains div's

XtendScott

6:49 am on Aug 29, 2007 (gmt 0)

10+ Year Member



DaveVK is on the right path, but I would do the following:

<style>
.hide div {
display:none;
}
</style>

<script type="javascript/text">
window.onload = document.getElementById("contentHide").className = "";
</script>

<div id="contentHide" class="hide">
<div id="whatever">some content here</div>
<div id="whatever2">some other content requiring javascript here</div>
<div id="whatever3">some more content here</div>
</div>

<noscript>some content here</noscript>