开发者

javascript turned off help

I am creating a small application where I am displaying some text wrapped in 3 divs so I am actually displaying 1 div at a time also there are prev and next buttons for users to toggle b开发者_如何学Goetween the div's. Now when javascript is turned off i just want to display 1 div without the prev and next buttons. I have and idea that it can be done with javascript by manipulating the CSS like.

document.getelementbyid("id1").style.display="visible";
document.getelementbyid("id1").style.display="none";

Thanks


You could use the <noscript> tag to both define the styles of the scripted elements and display your alternate div instead:

<noscript>
  <style type="text/css">
    #scripted-div1, #scripted-div2, #scripted-div3 { display:none; }
  </style>
  <div>
    <!-- Alternate content goes here -->
  </div>
</noscript> 


Arrange your default page view as it would be displayed with javascript turned off, and then, if it is on, you will be able to add desired elements into desired positions.


You can set those div's to display:none; (in CSS) by default, add id for both, and after page load set document.getelementbyid(..).style.display="visible"; (in JavaScript)

PS. u could use jquery or other, will be much more easy ;)

try this:

[style]#prev, #next { display:none; }
[js]
function showButtons()
{
    document.getElementById('next').style.display="block";
    document.getElementById('prev').style.display="block";
}
[html]
body onload="showButtons()">
div id="next">next..
div id="prev">prev..

This way without JS prev/next wont be displayed, and with JS they will show after page loads.


Maybe you could set the style inside a noscript tag.

Also, perhaps you should accept previous answers and respect the answers other have given you.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜