Advance Date +15 Days

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Christopher Benson-Manica

    #16
    Re: Hiding script with HTML comments

    Michael Winter <m.winter@bluey onder.co.invali d> wrote:
    [color=blue]
    > Script 'hiding' has been around for so long that many don't know why it
    > began in the first place, or that it stopped being necessary years ago.[/color]

    Does this truly go for all modern browsers, including PDA-based
    browsers? I believe we had a situation where some PDA browser
    actually crashed on <script> tags, although that wouldn't have been
    fixed by script hiding.

    --
    Christopher Benson-Manica | I *should* know what I'm talking about - if I
    ataru(at)cybers pace.org | don't, I need to know. Flames welcome.

    Comment

    • Michael Winter

      #17
      Re: Hiding script with HTML comments

      On 20/06/2005 19:16, Christopher Benson-Manica wrote:
      [color=blue]
      > Michael Winter <m.winter@bluey onder.co.invali d> wrote:
      >[color=green]
      >> Script 'hiding' [...] stopped being necessary years ago.[/color]
      >
      > Does this truly go for all modern browsers, including PDA-based
      > browsers?[/color]

      There's absolutely no reason why it shouldn't, but I didn't really mean
      to say 'all'. No-one could make that claim.

      All a user agent needs to do once it reads a SCRIPT opening tag is
      ignore everything until it encounters </ (though </script is probably
      safer). Even something that's strapped for resources should have no
      problem doing this as it needs to for SGML comments.

      The SCRIPT (and STYLE) elements were defined in 1996. If a user agent
      written after HTML 3.2 doesn't understand them, then it's broken. But,
      as I said elsewhere, if you have a genuine concern, then a better
      solution would be to move the script to an external file. Non-trivial
      scripts should be separated, anyway.

      [snip]

      Mike

      --
      Michael Winter
      Replace ".invalid" with ".uk" to reply by e-mail.

      Comment

      • Dr John Stockton

        #18
        Re: Advance Date +15 Days

        JRS: In article <d968u7$nup$05$ 1@news.t-online.com>, dated Mon, 20 Jun
        2005 13:24:49, seen in news:comp.lang. javascript, Daniel Kirsch
        <Iwillnotread_d aniel@gmx.de> posted :[color=blue]
        >Robert@BeatToB eat.com wrote:[color=green]
        >> I need this script to advance the document.write by 15 days,[/color]
        >
        >Maybe the following script might be of use for you:
        >
        >var fst = "+15d";
        >var dte = new Date();
        >var plusMinus = fst.match(/[+-]\d+[smhdy]/gi);
        >if (plusMinus) {
        > var vorz, shrt, val;
        > var multiplier = {"S":1,"M":60," H":3600,"d":864 00};
        > for (var i=0; i<plusMinus.len gth; i++) {
        > vorz = plusMinus[i].charAt(0) == "+" ? 1 : -1;
        > shrt = plusMinus[i].charAt(plusMin us[i].length-1);
        > val = vorz*Number(plu sMinus[i].substring(1,pl usMinus[i].length-1));
        > if (shrt == "m")
        > dte.setMonth(dt e.getMonth() + val);
        > else if (shrt.toLowerCa se() == "y")
        > dte.setFullYear (dte.getFullYea r() + val);
        > else if (multiplier[shrt])
        > dte.setTime(dte .getTime() + (val*multiplier[shrt]*1000));
        > }
        >}
        >alert(dte);[/color]



        Not good.

        If new Date('2005/10/21'); is used, then, since there are 31 days in
        October, the answer should be November 5th. However, if executed in the
        EU or in much of North America, the result will be in November 4th.

        Did you not see that I warned the OP "Ignore any response containing
        864e5 or its equivalent;"?

        See below.

        --
        © John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 IE 4 ©
        <URL:http://www.jibbering.c om/faq/> JL/RC: FAQ of news:comp.lang. javascript
        <URL:http://www.merlyn.demo n.co.uk/js-index.htm> jscr maths, dates, sources.
        <URL:http://www.merlyn.demo n.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.

        Comment

        • Richard Cornford

          #19
          Re: Hiding script with HTML comments

          T. Postel wrote:[color=blue]
          > Michael Winter wrote:
          >[color=green]
          >>The original point of 'hiding' was to make sure that an
          >>old browser (that is, old at the end of the last century)
          >>wouldn't show the contents of a SCRIPT element. All user
          >>agents now in use understand what a SCRIPT element is,
          >>whether they are capable of executing them or not, so
          >>this is entirely unnecessary. The fact that it persists
          >>in modern markup shows just how clueless some people are.[/color]
          >
          > However, several search engines do pay attention to HTML
          > comments and don't index keywords found inside them.[/color]

          Not indexing the contents of comments in HTML seems like a perfectly
          reasonable thing for a search engine to do. They are unlikely to contain
          anything of relevance to someone doing any sort of search.
          [color=blue]
          > Much modern usage of comment tags around <script> and
          > <style> code is to prevent search engines from displaying
          > pages which may contain keywords in the code.[/color]

          Is this true? Strictly speaking what appear to be HTML comments within
          SCRIPT and STYLE elements are not comments at all because the contents
          of those elements are CDATA so the HTML comment-like delimiters are no
          more than sequences of charters that resemble HTML comments. They only
          get to be HTML comments when the parser has no understanding of SCRIPT
          and STYLE elements.

          Now SCRIPT and STYLE elements have been with us for some considerable
          time, and browsers at least have understood how to handle them (either
          using them or ignoring their contents) for almost as long.

          So how does the writer of an HTML parser for a search engine come to be
          unfamiliar with the nature of SCIPT and STYLE elements? And how does the
          resulting search engine perform when it is diluting its usefulness
          considering identifiers, script comments and CSS class names.

          This sounds more like someone inventing a fairly tail to justify doing
          something that they could not find any other reason for doing. An
          nothing short of search engine documentation stating that they index
          SCRIPT and STYLE element content will convince me otherwise.
          [color=blue]
          > Perhaps there is more than one clue?[/color]

          Or a second type of clueless.

          Richard.


          Comment

          • Daniel Kirsch

            #20
            Re: Advance Date +15 Days

            Dr John Stockton wrote:[color=blue]
            > Not good.
            >
            > If new Date('2005/10/21'); is used, then, since there are 31 days in
            > October, the answer should be November 5th. However, if executed in the
            > EU or in much of North America, the result will be in November 4th.
            >
            > Did you not see that I warned the OP "Ignore any response containing
            > 864e5 or its equivalent;"?[/color]

            Thanks. Added
            if (shrt == "d")
            dte.setDate(dte .getDate() + val);

            Anything else "not good"?

            Daniel

            Comment

            • David Håsäther

              #21
              Re: Hiding script with HTML comments

              Michael Winter <m.winter@bluey onder.co.invali d> wrote:
              [color=blue]
              > All a user agent needs to do once it reads a SCRIPT opening tag is
              > ignore everything until it encounters </[/color]

              Pedantry: Actually, "</" followed by a name start character (a-zA-Z),
              i.e. ETAGO delmiter-in-context, or NET ("/") if the start tag was NET-
              enabling.

              --
              David Håsäther

              Comment

              • Dr John Stockton

                #22
                Re: Advance Date +15 Days

                JRS: In article <d98md2$db3$02$ 1@news.t-online.com>, dated Tue, 21 Jun
                2005 11:26:55, seen in news:comp.lang. javascript, Daniel Kirsch
                <Iwillnotread_d aniel@gmx.de> posted :[color=blue]
                >Dr John Stockton wrote:[color=green]
                >> Not good.
                >>
                >> If new Date('2005/10/21'); is used, then, since there are 31 days in
                >> October, the answer should be November 5th. However, if executed in the
                >> EU or in much of North America, the result will be in November 4th.
                >>
                >> Did you not see that I warned the OP "Ignore any response containing
                >> 864e5 or its equivalent;"?[/color]
                >
                >Thanks. Added
                > if (shrt == "d")
                > dte.setDate(dte .getDate() + val);
                >
                >Anything else "not good"?[/color]

                Well, the RegExp test should perhaps be case-sensitive; and you need to
                think about what +3H should do to Sun 2005/10/30 00:00:00. As you have
                it, it gives 2 o'clock; but with setHours it would give 3 o'clock.

                If the change cannot be done, the date should possibly be set to NaN.

                vorz = plusMinus[i].charAt(0) == "+" ? 1 : -1;
                or vorz = plusMinus[i].charAt(0) + "1" // ??

                Actually, you don't need vorz; RegExp match with
                X = fst.match(/([+-]\d+)([SMHdmy])/)
                then +X[1] can be used as val and X[2] as the selector.

                Note that a minute after 2005/10/30 01:59:30 it is actually 2005/10/30
                01:00:30.

                --
                © John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 IE 4 ©
                <URL:http://www.jibbering.c om/faq/> JL/RC: FAQ of news:comp.lang. javascript
                <URL:http://www.merlyn.demo n.co.uk/js-index.htm> jscr maths, dates, sources.
                <URL:http://www.merlyn.demo n.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.

                Comment

                • Daniel Kirsch

                  #23
                  Re: Advance Date +15 Days

                  Dr John Stockton wrote:[color=blue]
                  > Well, the RegExp test should perhaps be case-sensitive; and you need to
                  > think about what +3H should do to Sun 2005/10/30 00:00:00. As you have
                  > it, it gives 2 o'clock; but with setHours it would give 3 o'clock.[/color]

                  Of course. But that's pretty theoretical :-)
                  [color=blue]
                  > Actually, you don't need vorz; RegExp match with
                  > X = fst.match(/([+-]\d+)([SMHdmy])/)
                  > then +X[1] can be used as val and X[2] as the selector.[/color]

                  Thanks.

                  [color=blue]
                  > Note that a minute after 2005/10/30 01:59:30 it is actually 2005/10/30
                  > 01:00:30.[/color]

                  Works for me. It gives me "2:00:30".

                  Daniel

                  Comment

                  • Dr John Stockton

                    #24
                    Re: Advance Date +15 Days

                    JRS: In article <d9boc7$187$00$ 1@news.t-online.com>, dated Wed, 22 Jun
                    2005 15:19:02, seen in news:comp.lang. javascript, Daniel Kirsch
                    <Iwillnotread_d aniel@gmx.de> posted :[color=blue]
                    >Dr John Stockton wrote:[/color]
                    [color=blue][color=green]
                    >> Note that a minute after 2005/10/30 01:59:30 it is actually 2005/10/30
                    >> 01:00:30.[/color]
                    >
                    >Works for me. It gives me "2:00:30".[/color]

                    Yes; but you're presumably in Germany. Try it in German time, a clock
                    hour later.

                    --
                    © John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 MIME. ©
                    Web <URL:http://www.merlyn.demo n.co.uk/> - w. FAQish topics, links, acronyms
                    PAS EXE etc : <URL:http://www.merlyn.demo n.co.uk/programs/> - see 00index.htm
                    Dates - miscdate.htm moredate.htm js-dates.htm pas-time.htm critdate.htm etc.

                    Comment

                    • cwdjrxyz@yahoo.com

                      #25
                      Re: Hiding script with HTML comments

                      > Michael Winter <m.win...@bluey onder.co.invali ­d> wrote:
                      [color=blue]
                      >Script 'hiding' has been around for so long that many don't know why it[/color]
                      began in the first place, or that it stopped being necessary years ago.

                      I wonder if you can say the same about multi-line comment tags around
                      CDATA open and close tags placed in a script in a few years. In xhtml
                      you are required to surround the script with open and close CDATA tags
                      to avoid possible conflict with xml, if any is included in the xhtml
                      page. The problem is that most current browsers do not understand the
                      xml CDATA tags and completely kill the script, if you use them. The W3C
                      xhtml 1.0 and 1.1 validators will validate such a page perfectly, if it
                      has no errors. However if you leave the CDATA tags off, the validators
                      make a terrible fuss. However if you surround the CDATA open and close
                      tags with the multi-line javascript tags, everyone is happy. The page
                      works, and the validators and a proper xhtml delivery see right through
                      the javascripts to view the XML CDATA tags. I believe I first learned
                      about this at the Opera forum nearly 2 years ago from a member of the
                      Opera design team. Of course the easy way out is to use an external
                      javascript file, which avoids all of this fuss. However, many still
                      insist on including the script on the main page.

                      PS The Google beta groups site has been acting up at times for the last
                      day or two. It sometimes does not put the quoted message in the text
                      box, and you have to highlight and copy it to the response text box.
                      Until this problem resolves, some posts made from Google are going to
                      look strange. Major US ISPs including MSN and AOL have dropped Usenet
                      groups. I and many others are not interested in newsreaders just to
                      make a few posts in Usenet. Nearly everyone I know reads NGs online.
                      Most plans here allow unlimited, or very large, time on line, and many
                      even with dialup leave the computer on for many hours at a time.

                      Comment

                      • Michael Winter

                        #26
                        Re: Hiding script with HTML comments

                        On 23/06/2005 09:40, cwdjrxyz@yahoo. com wrote:

                        [snip]
                        [color=blue]
                        > The problem is that most current browsers do not understand the
                        > xml CDATA tags and completely kill the script, if you use them.[/color]

                        The rather blatantly obvious solution is to not serve XHTML(-like)
                        documents to user agents that don't explicitly state[1] they support it.

                        There is no benefit in serving XHTML as text/html, and XML tools can
                        transform their output to HTML so there is no excuse here, either.

                        [snip]

                        Mike


                        [1] IE says it supports anything in its request headers, so you have to
                        ignore things like that when negotiating XHTML.

                        --
                        Michael Winter
                        Replace ".invalid" with ".uk" to reply by e-mail.

                        Comment

                        • Dr John Stockton

                          #27
                          Re: Hiding script with HTML comments

                          JRS: In article <1119516020.855 751.61640@g47g2 000cwa.googlegr oups.com>,
                          dated Thu, 23 Jun 2005 01:40:20, seen in news:comp.lang. javascript,
                          cwdjrxyz@yahoo. com <cwdjrxyz@yahoo .com> posted :[color=blue]
                          >
                          >PS The Google beta groups site has been acting up at times for the last
                          >day or two. It sometimes does not put the quoted message in the text
                          >box, and you have to highlight and copy it to the response text box.
                          >Until this problem resolves, some posts made from Google are going to
                          >look strange. Major US ISPs including MSN and AOL have dropped Usenet
                          >groups. I and many others are not interested in newsreaders just to
                          >make a few posts in Usenet. Nearly everyone I know reads NGs online.
                          >Most plans here allow unlimited, or very large, time on line, and many
                          >even with dialup leave the computer on for many hours at a time.[/color]

                          If providers in your country provide only shoddy services, it is you who
                          should suffer, not us; you merit no sympathy. Pay for a good service,
                          and demand it.


                          If you find that, when you start a News reply, Google does not provide
                          the previous article in quoted form, note what Keith Thompson wrote in
                          comp.lang.c, message ID <lnwtuhfy7d.fsf @nuthaus.mib.or g> :-
                          If you want to post a followup via groups.google.c om, don't use
                          the "Reply" link at the bottom of the article. Click on "show
                          options" at the top of the article, then click on the "Reply" at
                          the bottom of the article headers.

                          Since that is what the experts in this newsgroup prefer to read, it will
                          be to your advantage to comply.

                          --
                          © John Stockton, Surrey, UK. ???@merlyn.demo n.co.uk Turnpike v4.00 MIME. ©
                          Web <URL:http://www.merlyn.demo n.co.uk/> - FAQish topics, acronyms, & links.
                          Check boilerplate spelling -- error is a public sign of incompetence.
                          Never fully trust an article from a poster who gives no full real name.

                          Comment

                          • Thomas 'PointedEars' Lahn

                            #28
                            Re: Advance Date +15 Days

                            Dr John Stockton wrote:
                            [color=blue]
                            > JRS: In article <d9boc7$187$00$ 1@news.t-online.com>, dated Wed, 22 Jun
                            > 2005 15:19:02, seen in news:comp.lang. javascript, Daniel Kirsch
                            > <Iwillnotread_d aniel@gmx.de> posted :[color=green]
                            >>Dr John Stockton wrote:[color=darkred]
                            >>> Note that a minute after 2005/10/30 01:59:30 it is actually 2005/10/30
                            >>> 01:00:30.[/color]
                            >> Works for me. It gives me "2:00:30".[/color]
                            >
                            > Yes; but you're presumably in Germany. Try it in German time,
                            > a clock hour later.[/color]

                            I am in Germany where next change from Daylight Saving Time to
                            "normal" time is scheduled on Sunday, 2005-10-30, 03:00:00.000
                            local (DS)time, using the German time locale.

                            Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.8) Gecko/20050610
                            Firefox/1.0.4 (Debian package 1.0.4-3) Mnenhy/0.7.2.0

                            shows for `new Date(2005, 9, 30, 1, 59)'
                            "Sun Oct 30 2005 01:59:00 GMT+0200 (CEST)"
                            which is correct;

                            for `new Date(2005, 9, 30, 2, 59)'
                            "Sun Oct 30 2005 02:59:00 GMT+0100 (CET)"
                            which is incorrect

                            and so for `new Date(new Date(2005, 9, 30, 2, 59).getTime() + 3600000)'
                            "Sun Oct 30 2005 03:59:00 GMT+0100 (CET)"
                            which is correct according to "common sense".

                            Apparently, the JavaScript 1.5 engine of my UA is not up to date or not
                            properly using the locale. The second expression should have given

                            "Sun Oct 30 2005 02:59:00 GMT+0200 (CEST)"

                            as change from local DST to local "normal" time is scheduled only a
                            minute later (ref. <http://zeitumstellung. de/>). Or am I missing
                            something?


                            PointedEars

                            Comment

                            • Thomas 'PointedEars' Lahn

                              #29
                              Re: Hiding script with HTML comments

                              cwdjrxyz@yahoo. com wrote:
                              [color=blue][color=green]
                              >> Michael Winter <m.win...@bluey onder.co.invali ­d> wrote:
                              >> Script 'hiding' has been around for so long that many don't know why it[/color]
                              > began in the first place, or that it stopped being necessary years ago.[/color]
                              ^^
                              This quote is borken, although Google Groups may error-correct that for
                              display. The technical flaws of Google Groups posts are many, especially
                              in the new version; please avoid using it, use a proper newsreader
                              application instead.
                              [color=blue]
                              > I wonder if you can say the same about multi-line comment tags around
                              > CDATA open and close tags placed in a script in a few years. In xhtml
                              > you are required to surround the script with open and close CDATA tags
                              > to avoid possible conflict with xml, if any is included in the xhtml
                              > page.[/color]

                              No, you are not. As it is but a PCDATA issue, you may instead escape markup
                              characters within the PCDATA content that script or style content is in
                              XHTML, e.g. `&lt;' for `<' (JS: less-than operator; CSS: child selector),
                              &gt; for `>' (JS: greater-than operator) and so on.

                              It is only that the UA(s) tested with or targeted, most notably Internet
                              Explorer, are not capable of processing XHTML and so do not support CDATA
                              _content declarations_ which is why commenting out those declarations is
                              necessary; not using the unsupported markup language in the first place
                              (but sticking to widely, if not always, supported HTML 4.01, Strict DTD
                              if possible) or including/linking to a script or style file would have
                              avoided the original problem.


                              PointedEars

                              Comment

                              • Dr John Stockton

                                #30
                                Re: Advance Date +15 Days

                                JRS: In article <4796935.ZtuNWH zeWK@PointedEar s.de>, dated Sun, 3 Jul
                                2005 19:40:18, seen in news:comp.lang. javascript, Thomas 'PointedEars'
                                Lahn <PointedEars@we b.de> posted :[color=blue]
                                >Dr John Stockton wrote:[/color]
                                (about ten days ago)
                                [color=blue][color=green]
                                >> JRS: In article <d9boc7$187$00$ 1@news.t-online.com>, dated Wed, 22 Jun
                                >> 2005 15:19:02, seen in news:comp.lang. javascript, Daniel Kirsch
                                >> <Iwillnotread_d aniel@gmx.de> posted :[color=darkred]
                                >>>Dr John Stockton wrote:
                                >>>> Note that a minute after 2005/10/30 01:59:30 it is actually 2005/10/30
                                >>>> 01:00:30.
                                >>> Works for me. It gives me "2:00:30".[/color]
                                >>
                                >> Yes; but you're presumably in Germany. Try it in German time,
                                >> a clock hour later.[/color]
                                >
                                >I am in Germany[/color]

                                [color=blue]
                                >Apparently, the JavaScript 1.5 engine of my UA is not up to date or not
                                >properly using the locale. The second expression should have given
                                >
                                >"Sun Oct 30 2005 02:59:00 GMT+0200 (CEST)"
                                >
                                >as change from local DST to local "normal" time is scheduled only a
                                >minute later (ref. <http://zeitumstellung. de/>). Or am I missing
                                >something?[/color]

                                Probably.

                                Rather than looking at such as
                                new Date(2005, 9, 30, 1, 59)
                                it would be simpler to look at
                                new Date(2005, 9, 30, 1, 59).getTimezone Offset()
                                or
                                new Date("2005/10/30 00:59:00 GMT").getTimezo neOffset()

                                One can get javascript to determine when the clock change is thought to
                                occur : <URL:http://www.merlyn.demo n.co.uk/js-clndr.htm#Ctrls > shows it.

                                Unfortunately, operating systems are often written and configured in a
                                country which has a considerable reputation for ignorance both about
                                time and about the rest of the world; so your OS may have incorrect
                                data.


                                You wrote :
                                for `new Date(2005, 9, 30, 2, 59)'
                                "Sun Oct 30 2005 02:59:00 GMT+0100 (CET)"
                                which is incorrect
                                Is it? Local time 02:59 occurs twice, once at the end of Summer and
                                once at the start of Winter, and ISTM that you see the latter. After
                                the clock has been put back, it continues going forwards.

                                Indeed, AIUI, the first version of Windows 95 (cf. ibid. 13,14/19) sets
                                the clock back whenever it thinks that the clock has reached 2 a.m. on
                                the day in question, not just on the first occasion.

                                --
                                © John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 MIME. ©
                                Web <URL:http://www.merlyn.demo n.co.uk/> - w. FAQish topics, links, acronyms
                                PAS EXE etc : <URL:http://www.merlyn.demo n.co.uk/programs/> - see 00index.htm
                                Dates - miscdate.htm moredate.htm js-dates.htm pas-time.htm critdate.htm etc.

                                Comment

                                Working...