SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Zealot
    Join Date
    Nov 2007
    Posts
    129
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    displaying content if javascript is disabled

    Hi there,

    I have a jQuery banner slider, but I would like to know if it is possible to display different content (or the first slide only), if JavaScript is disabled.

    This is my content:

    Code:
    <div id="slider">
          <ul id="slider1">
            
            <!-- slide #1 -->
            <li>
              <h1>my heading</h1>
              <h2>sub heading</h2>
                  <p>slide content</p>
            </li>
            <!-- end slide #1 --> 
            
            <!-- slide #2 -->
            <li>
              <h1>my heading</h1>
              <h2>sub heading</h2>
                  <p>slide content</p>
            </li>
            <!-- end slide #2 -->
            
          </ul>
        </div>
    Any help would be great! Thanks

  2. #2
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,862
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    To have content that displays if JavaScript is disabled you simply include it in the page to start with. You then hide it using JavaScript. If JavaScript is disabled then the code to hide it doesn'tr run and that content remains visible.

    You can also do it with blocks of content by wrapping the block in <noscript> tags but using JavaScript is more lfexible as you can update inline content rather than just blocks as well as testing that the JavaScript commands your script uses are available.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •