Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Master Coder
    Join Date
    Apr 2003
    Location
    in my house
    Posts
    5,211
    Thanks
    39
    Thanked 201 Times in 197 Posts

    script/noscript issue

    Hi,

    I have utilised noscript, to show a warning to visitors. and my js is (obviously), inside script tags. However, I want my whole js powered code no to show if js is disabled. what tag need I use to achieve this?

    bazz
    "The day you stop learning is the day you become obsolete"! - my late Dad.

    Why do some people say "I don't know for sure"? If they don't know for sure then, they don't know!
    Useful MySQL resource
    Useful MySQL link

  • #2
    Senior Coder timgolding's Avatar
    Join Date
    Aug 2006
    Location
    Southampton
    Posts
    1,519
    Thanks
    114
    Thanked 110 Times in 109 Posts
    Quote Originally Posted by bazz View Post
    Hi,

    I have utilised noscript, to show a warning to visitors. and my js is (obviously), inside script tags. However, I want my whole js powered code no to show if js is disabled. what tag need I use to achieve this?

    bazz
    Something like this
    Code:
    <noscript>
    Whatever goes here
    </noscript>
    <script type="text/javascript">
    <!--
    Your script code
    -->
    </script>
    its the <!-- and --> that hide your script code when JS is not present
    You can not say you know how to do something, until you can teach it to someone else.

  • #3
    Master Coder
    Join Date
    Apr 2003
    Location
    in my house
    Posts
    5,211
    Thanks
    39
    Thanked 201 Times in 197 Posts
    thanks for the quick response. I guess I should have put this in the js forum so would a mod please move it there. (thanks)

    ok, then here is my html output
    Code:
    <noscript>
    <p class='warning'>
    Please enable Javascript so that you can add extras to your chosen room.
    </p>
    </noscript>
    
    <script type="text/javascript" language="javascript">
    //<![CDATA[
    
      function HidePart(d) { document.getElementById(d).style.display = "none";  } 
      function ShowPart(d) { document.getElementById(d).style.display = "block"; }
      function CheckboxChecked(b,d)
      {
        if(b) { ShowPart(d); }
        else  { HidePart(d); }
      }
    // ]]>
      </script>
     
     
        <input type="checkbox" onclick="CheckboxChecked(this.checked,'Airport Pick-up')" />  
        Airport Pick-up <br />
    
        <div id="Airport Pick-up" style="display:none">
          <table>
       
            <tr>
              <td class="right_side">
              <input type="checkbox" name="Airport Pick-up" value="Courtesy Car" /> Courtesy Car </td>
        
              <td class="right_side">20.00 GBP</td>
            </tr>
    
          
            <tr>
              <td><p></p>
              </td>
            </tr>
          </table>
        </div>
    I thought 'document.write' might help but it seems not to output it all and therefore messes it up.

    code with document.write attempt
    Code:
     
    <noscript>
    <p class='warning'>
    Please enable Javascript so that you can add extras to your chosen room.
    </p>
    </noscript>
    <script type="text/javascript" language="javascript">
    //<![CDATA[
    
      function HidePart(d) { document.getElementById(d).style.display = "none";  } 
      function ShowPart(d) { document.getElementById(d).style.display = "block"; }
      function CheckboxChecked(b,d)
      {
        if(b) { ShowPart(d); }
        else  { HidePart(d); }
      }
    // ]]>
      </script>
    
     -- works fine up to this point.
     
    <script type='text/javascript'>
    document.write("<input type ='checkbox' onclick="CheckboxChecked(this.checked, 'Airport Pick-up')" />");
    document.write("Airport Pick-up <br />");
    document.write(" <div id="Airport Pick-up" style="display:none"><table> ");
     
            <tr>
              <td class="right_side">
              <input type="checkbox" name="Airport Pick-up" value="Courtesy Car" /> Courtesy Car </td>
        
              <td class="right_side">20.00 GBP</td>
            </tr>
          
            <tr>
              <td><p></p>
              </td>
            </tr>
          </table></script>
    
        </div>
        
    <script type='text/javascript'>
    document.write("<input type ='checkbox' onclick="CheckboxChecked(this.checked, 'Bathing ')" />");
    document.write("Bathing  <br />");
    document.write(" <div id="Bathing " style="display:none"><table> ");
     
            <tr>
              <td class="right_side">
              <input type="checkbox" name="Bathing " value="Bath Robes - Luxurious Monogrammed" /> Bath Robes - Luxurious Monogrammed </td>
        
              <td class="right_side">2.50 GBP</td>
            </tr>
           
            <tr>
              <td class="right_side">
              <input type="checkbox" name="Bathing " value="Bath Robes" /> Bath Robes </td>
        
              <td class='right_side'> No Charge </td>
          
            <tr>
              <td><p></p>
              </td>
            </tr>
          </table></script>
        </div>
    I am confused a bit further because I am doing this server side with mysql db data. As may be clear, the data in the table, is returned in a server-side loop. how can I output the td's and stuff inside js (if that's how I should be doing it)

    any pointers would be most welcome.

    bazz
    "The day you stop learning is the day you become obsolete"! - my late Dad.

    Why do some people say "I don't know for sure"? If they don't know for sure then, they don't know!
    Useful MySQL resource
    Useful MySQL link

  • #4
    New Coder
    Join Date
    Mar 2009
    Location
    Fabric Covered Box
    Posts
    69
    Thanks
    1
    Thanked 16 Times in 14 Posts
    Code:
    <noscript>
      <style type='text/css'>
      .stuffThatShouldNotBeSeenIfJavascriptIsDisabled { display:none }
      </style>
    </noscript>
    
    ...
    
    <div class='stuffThatShouldNotBeSeenIfJavascriptIsDisabled'>...</div>


  •  

    Posting Permissions

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