dcsimg
www.webdeveloper.com
Results 1 to 6 of 6

Thread: script with valid NOSCRIPT

  1. #1
    Join Date
    Dec 2004
    Posts
    2

    Question script with valid NOSCRIPT

    Hello world. I took, from this site, a javascript to allow the date and time to be displayed on my site.

    when i run an accessiblity check on the page the script appears in the check tells me it has failed due to the script not have an associated valid NOSCRIPT.

    Not having any experience with Java before, i'm at a loss as how to fix this... it's prob. very simple ... help please.

    the script is below:

    <script language=JavaScript class="text">
    <!-- This script and many more are available free online at -->
    <!-- The JavaScript Source!! http://javascript.internet.com -->
    <!-- Begin
    var day="";
    var month="";
    var myweekday="";
    var year="";
    newdate = new Date();
    mydate = new Date();
    dston = new Date('April 4, 2001 2:59:59');
    dstoff = new Date('october 31, 2001 2:59:59');
    var myzone = newdate.getTimezoneOffset();
    newtime=newdate.getTime();
    var zone = 0; // references your time zone
    if (newdate > dston && newdate < dstoff ) {
    zonea = zone - 1 ;
    dst = " British Summer Time";
    }
    else {
    zonea = zone ; dst = " Pacific Standard Time";
    }
    var newzone = (zonea*60*60*1000);
    newtimea = newtime+(myzone*60*1000)-newzone;
    mydate.setTime(newtimea);
    myday = mydate.getDay();
    mymonth = mydate.getMonth();
    myweekday= mydate.getDate();
    myyear= mydate.getYear();
    year = myyear;
    if (year < 2000) // Y2K Fix, Isaac Powell
    year = year + 1900; // http://onyx.idbsu.edu/~ipowell
    myhours = mydate.getHours();
    if (myhours >= 12) {
    if (myhours >= 18) {
    myhours = (myhours == 18) ? 0 : myhours; mm = "";
    }
    else {
    myhours = (myhours == 12) ? 12 : myhours; mm = "";
    }}
    else {
    myhours = (myhours == 0) ? 12 : myhours; mm = "";
    }
    myminutes = mydate.getMinutes();
    if (myminutes < 10){
    mytime = ":0" + myminutes;
    }
    else {
    mytime = ":" + myminutes;
    };
    arday = new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
    armonth = new Array("January ","February ","March ","April ","May ","June ","July ","August ","September ", "October ","November ","December ")
    ardate = new Array("0th","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","2 0","21","22","23","24","25","26","27","28","29","30","31");
    // rename locale as needed.
    var time = (arday[myday] + " " + ardate[myweekday] + " " + armonth[mymonth] + " " + year+"<br>" + mm +"");
    document.write(time);
    //--></script>
    &nbsp;</p>
    </div></td>

  2. #2
    Join Date
    Feb 2003
    Location
    Wales, UK
    Posts
    3,147

  3. #3
    Join Date
    Dec 2004
    Posts
    2

    Noscript no working

    Hi, DaveSW, I did try your suggestion of adding a NOSCRIPT, which was great, thanks. Thing is, when tested in the format suggested by WC3 it's still not passing the accessibility check. the code added was as follows:

    would you mind having a look & just telling me if I'm missing something really obvious?

    thanks, CB


    <script language=JavaScript class="text">
    <!-- This script and many more are available free online at -->
    <!-- The JavaScript Source!! http://javascript.internet.com -->
    <!-- Begin
    var day="";
    var month="";
    var myweekday="";
    var year="";
    newdate = new Date();
    mydate = new Date();
    dston = new Date('April 4, 2001 2:59:59');
    dstoff = new Date('october 31, 2001 2:59:59');
    var myzone = newdate.getTimezoneOffset();
    newtime=newdate.getTime();
    var zone = 0; // references your time zone
    if (newdate > dston && newdate < dstoff ) {
    zonea = zone - 1 ;
    dst = " British Summer Time";
    }
    else {
    zonea = zone ; dst = " Pacific Standard Time";
    }
    var newzone = (zonea*60*60*1000);
    newtimea = newtime+(myzone*60*1000)-newzone;
    mydate.setTime(newtimea);
    myday = mydate.getDay();
    mymonth = mydate.getMonth();
    myweekday= mydate.getDate();
    myyear= mydate.getYear();
    year = myyear;
    if (year < 2000) // Y2K Fix, Isaac Powell
    year = year + 1900; // http://onyx.idbsu.edu/~ipowell
    myhours = mydate.getHours();
    if (myhours >= 12) {
    if (myhours >= 18) {
    myhours = (myhours == 18) ? 0 : myhours; mm = "";
    }
    else {
    myhours = (myhours == 12) ? 12 : myhours; mm = "";
    }}
    else {
    myhours = (myhours == 0) ? 12 : myhours; mm = "";
    }
    myminutes = mydate.getMinutes();
    if (myminutes < 10){
    mytime = ":0" + myminutes;
    }
    else {
    mytime = ":" + myminutes;
    };
    arday = new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
    armonth = new Array("January ","February ","March ","April ","May ","June ","July ","August ","September ", "October ","November ","December ")
    ardate = new Array("0th","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","2 0","21","22","23","24","25","26","27","28","29","30","31");
    // rename locale as needed.
    var time = (arday[myday] + " " + ardate[myweekday] + " " + armonth[mymonth] + " " + year+"<br>" + mm +"");
    document.write(time);
    //--></script>
    <noscript>
    It appears that your browser does not support JavaScript, or you have it disabled. This site is best viewed with JavaScript enabled.<p>If JavaScript is disabled in your browser, please turn it back on then reload this page.<p>Or, if your browser does not support JavaScript,
    click <a href="http://www.dls.org.uk/Text/textframe.htm">here</a>.
    </noscript>

  4. #4
    Join Date
    Nov 2003
    Location
    Germany, Europe
    Posts
    100

    2 errors

    CrispyBuck it is obvious that it does not validate for the one or both reasons below:

    1. The "class" attribute is not valid for the "script" element. The valid attributes for this element are: "charset", "defer", "event", "for", "language", "runat", "src", "type", and "xml:space".

    2. HTML 4.01 and XHTML require the "type" attribute to specify the scripting language for the "script" element. For example, use type="text/javascript" for JavaScript. Note that some browsers may work without this attribute but it is highly recommended that it be used.

  5. #5
    Join Date
    Nov 2002
    Location
    Baltimore, Maryland
    Posts
    12,279
    Users aren't using JavaScript for good reasons, and some of them because of some disability. Using the NOSCRIPT element to tell them to enable JavaScript is offensive.
    “The power of the Web is in its universality. Access by everyone regardless of disability is an essential aspect.”
    —Tim Berners-Lee, W3C Director and inventor of the World Wide Web

  6. #6
    Join Date
    Nov 2003
    Location
    Germany, Europe
    Posts
    100

    Exclamation Don't rely on JavaScript

    I must agree with Charles.
    JavaScript is not supported by all browsers and some users disable it. When JavaScript is used, it should not be relied upon.
    In such cases you will disable your visitor to access your content.
    You should avoid as far as possible implementing JavaScript, to avoid running risks on complications on the end users machines, or while goverment and other employees are required to disable this feature, for security or other reasons. Also there is a number of users who are very concerned about security issues and disable this feature too.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles