SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Evangelist
    Join Date
    Jul 2004
    Location
    England
    Posts
    588
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    <noscript> include

    I use a .php suffix on my pages and want too be able to include a file for sitewide use to display a <noscript> message when js is required.

    Efforts thus far haven't worked.

    Suggestions appreciated. Please and thanks.

  2. #2
    Function Curry'er JimmyP's Avatar
    Join Date
    Aug 2007
    Location
    Brighton, UK
    Posts
    2,006
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You should not really use the noscript tag because it's not always a user's browser which disables JS... Sometimes it is a firewall, in which case the noscript tag is ineffective.

    Try this way instead:

    Put this anywhere on your page:
    Code HTML4Strict:
    <p id="message">
    You Do not have JS enabled!!!
    </p>

    Some CSS: (put in stylesheet or style tag in head section) - This CSS is not necessary.
    Code CSS:
    p#message {
       display: block;
       position: absolute;
       top: 10px;
       left: 10px;
       padding: 10px; 
       background: #FFFF00;
       color: #000;
    }

    And some JS to go just above the </body> tag::

    Code JavaScript:
    <script type="text/javascript">
    document.getElementById("message").style.visibility = "hidden";
    </script>

    This makes the message visible by default. If the user happens to have JS enabled then the message will dissapear.
    James Padolsey
    末末末末末末末末末末末末末末末末末末末
    Awesome JavaScript Zoomer (demo here)
    'Ajaxy' - Ajax integration solution (demo here)

  3. #3
    Function Curry'er JimmyP's Avatar
    Join Date
    Aug 2007
    Location
    Brighton, UK
    Posts
    2,006
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I was not too sure what you meant when you mentioned php suffix etc... - not sure how it relates...?
    James Padolsey
    末末末末末末末末末末末末末末末末末末末
    Awesome JavaScript Zoomer (demo here)
    'Ajaxy' - Ajax integration solution (demo here)

  4. #4
    SitePoint Evangelist
    Join Date
    Jul 2004
    Location
    England
    Posts
    588
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hhhmmm... interesting. Thanks.

    So that's cross-browser reliable in stances where browser js is off or blocked by firewall?

    'php suffix'... my pages are .php rather than .htm etc - and so affects the method by which includes are called.

  5. #5
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,786
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    The way includes are called has nothing to do with JavaScript.
    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="^$">

  6. #6
    bronze trophy
    Join Date
    Dec 2004
    Location
    Sweden
    Posts
    2,670
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by JimmyPaddy View Post
    Code JavaScript:
    <script type="text/javascript">
    document.getElementById("message").style.visibility = "hidden";
    </script>

    This makes the message visible by default. If the user happens to have JS enabled then the message will dissapear.
    Only if CSS is also enabled.

    To actually remove it, do this:
    Code:
    var message = document.getElementById("message");
    message.parentNode.removeChild(message);
    Simon Pieters


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
  •