FAQ Questions

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Randy Webb

    FAQ Questions

    Just for my own curiosity, what ever happend to the Java Applet that was
    referenced in the FAQ along with the HTTPRequestObje ct?


    And in http://jibbering.com/faq/#FAQ4_43, any chance of adding a snippet
    about this bookmarklet:

    javascript:'<co de><ol><li>'+(d ocument.documen tElement||docum ent.body).outer HTML.replace(/&/g,"&amp;").repl ace(/</g,"&lt;").repla ce(/%20%20/g,"&nbsp;%20"). replace(/\n/g,"<li>")+'<\/ol><\/code>';

    I don't recall who wrote it, but it gives you the source of the
    document, with line numbers, to make debugging in IE a lot simpler.

    <FAQENTRY>
    --
    Randy
    comp.lang.javas cript FAQ - http://jibbering.com/faq
  • Martin Honnen

    #2
    Re: FAQ Questions



    Randy Webb wrote:
    [color=blue]
    > Just for my own curiosity, what ever happend to the Java Applet that was
    > referenced in the FAQ along with the HTTPRequestObje ct?
    > http://jibbering.com/faq/#FAQ4_34[/color]

    I think the applet is here:

    though I am not sure about that. And I don't edit the FAQ so I don't
    know why the link is no longer there, maybe the restrictions to the free
    version of the applet are a reason for that.


    --

    Martin Honnen

    Comment

    • Robert

      #3
      Re: FAQ Questions

      > And in http://jibbering.com/faq/#FAQ4_43, any chance of adding a snippet[color=blue]
      > about this bookmarklet:
      >
      > javascript:'<co de><ol><li>'+([/color]
      document.docume ntElement||docu ment.body).oute rHTML.replace(
      /&/g,"&amp;").repl ace(/</g,"&lt;").repla ce(/%20%20/g,"&nbsp;%20"). replace(
      /\n/g,"<li>")+'<\/ol><\/code>';

      I think more testing would be needed on the MacOS version of IE. I
      got only one line to display when I visited the Yahoo site. The yahoo
      site has a javascript error today.

      I picked this line up in this forum. I did not record the author. I
      belive it would work with more browsers. It is a good way to display
      the resulting html source if you are using document.write:

      javascript:(doc ument.documentE lement||documen t.body).innerHT ML.replace(
      /&/g,%22&amp;%22). replace(
      /</g,%22&lt;%22).r eplace(/\n/g,%22<br>%22)

      You may need to delete the line ends when making it into a bookmark.

      These lines would be a good addition to the FAQ.

      Robert

      Comment

      • Richard Cornford

        #4
        Re: FAQ Questions

        Randy Webb wrote:[color=blue]
        > Just for my own curiosity, what ever happend to the Java
        > Applet that was referenced in the FAQ along with the
        > HTTPRequestObje ct?
        > http://jibbering.com/faq/#FAQ4_34[/color]

        Did you mean:-

        <URL: http://jibbering.com/faq/#FAQ4_38 >

        - which has the link to the Galasoft applet?
        [color=blue]
        > And in http://jibbering.com/faq/#FAQ4_43, any chance of
        > adding a snippet about this bookmarklet:
        >
        > javascript:'<co de><ol><li>'+
        > (document.docum entElement||doc ument.body).
        > outerHTML.repla ce(/&/g,"&amp;").
        > replace(/</g,"&lt;").repla ce(/%20%20/g,"&nbsp;20") .
        > replace(/\n/g,"<li>")+'<\/ol><\/code>';
        >
        > I don't recall who wrote it, but it gives you the
        > source of the document, with line numbers, to make
        > debugging in IE a lot simpler.[/color]

        As an addition to FAQ4_43 it would make most sense as part of a page on
        client-side debugging strategies. However, I have often thought that it
        might be a good idea to put a page of javascript URL together. A
        collection that could include URLs useful for debugging, but also
        examples of how they may be used to subvert things like javascript
        validation (as a lesson in why client-side validation should not be used
        on its own).

        Richard.


        Comment

        • Randy Webb

          #5
          Re: FAQ Questions

          Robert wrote:
          [color=blue][color=green]
          >>And in http://jibbering.com/faq/#FAQ4_43, any chance of adding a snippet
          >>about this bookmarklet:
          >>
          >>javascript:'< code><ol><li>'+ ([/color]
          >
          > document.docume ntElement||docu ment.body).oute rHTML.replace(
          > /&/g,"&amp;").repl ace(/</g,"&lt;").repla ce(/%20%20/g,"&nbsp;%20"). replace(
          > /\n/g,"<li>")+'<\/ol><\/code>';
          >
          > I think more testing would be needed on the MacOS version of IE. I
          > got only one line to display when I visited the Yahoo site. The yahoo
          > site has a javascript error today.
          >
          > I picked this line up in this forum. I did not record the author. I
          > belive it would work with more browsers. It is a good way to display
          > the resulting html source if you are using document.write:
          >
          > javascript:(doc ument.documentE lement||documen t.body).innerHT ML.replace(
          > /&/g,%22&amp;%22). replace(
          > /</g,%22&lt;%22).r eplace(/\n/g,%22<br>%22)[/color]

          The only two differences in the two is that the first one numbers the
          lines, which makes it a lot easier to see where a particular line number
          is. The other difference is outerHTML versus innerHTML. Does outerHTML
          work in IE on the MAC?

          I believe mine and yours both came from the same thread though.

          --
          Randy
          comp.lang.javas cript FAQ - http://jibbering.com/faq

          Comment

          • Randy Webb

            #6
            Re: FAQ Questions

            Richard Cornford wrote:
            [color=blue]
            > Randy Webb wrote:
            >[color=green]
            >>Just for my own curiosity, what ever happend to the Java
            >>Applet that was referenced in the FAQ along with the
            >>HTTPRequestOb ject?
            >>http://jibbering.com/faq/#FAQ4_34[/color]
            >
            >
            > Did you mean:-
            >
            > <URL: http://jibbering.com/faq/#FAQ4_38 >
            >
            > - which has the link to the Galasoft applet?[/color]

            Nah, I looked at the wrong one. Maybe thats why I didn't see it :)
            [color=blue]
            >[color=green]
            >>And in http://jibbering.com/faq/#FAQ4_43, any chance of
            >>adding a snippet about this bookmarklet:
            >>
            >>javascript:'< code><ol><li>'+
            >>(document.doc umentElement||d ocument.body).
            >>outerHTML.rep lace(/&/g,"&amp;").
            >>replace(/</g,"&lt;").repla ce(/%20%20/g,"&nbsp;20") .
            >>replace(/\n/g,"<li>")+'<\/ol><\/code>';
            >>
            >>I don't recall who wrote it, but it gives you the
            >>source of the document, with line numbers, to make
            >>debugging in IE a lot simpler.[/color]
            >
            >
            > As an addition to FAQ4_43 it would make most sense as part of a page on
            > client-side debugging strategies. However, I have often thought that it
            > might be a good idea to put a page of javascript URL together. A
            > collection that could include URLs useful for debugging, but also
            > examples of how they may be used to subvert things like javascript
            > validation (as a lesson in why client-side validation should not be used
            > on its own).[/color]

            Yes, 4_43 would be a good place for it (or a link to it).

            --
            Randy
            comp.lang.javas cript FAQ - http://jibbering.com/faq

            Comment

            • Robert

              #7
              Re: FAQ Questions

              Randy Webb <HikksNotAtHome @aol.com> wrote in message[color=blue]
              > The only two differences in the two is that the first one numbers the
              > lines, which makes it a lot easier to see where a particular line number
              > is. The other difference is outerHTML versus innerHTML. Does outerHTML
              > work in IE on the MAC?[/color]

              I had to change the \n to \r to get this one line of Javascript to
              work on MacOS 10.2.6 for IE 5.2.

              javascript:'<co de><ol><li>'+(
              document.docume ntElement||docu ment.body).oute rHTML.replace(
              /&/g,"&amp;").repl ace(/</g,"&lt;").repla ce(
              /%20%20/g,"&nbsp;%20"). replace(
              /\r/g,"<li>")+'<\/ol><\/code>';


              To mark the end of a line in a text file (...), the MacOS uses a
              carriage return (CR, ASCII 13), UNIX uses a line feed (LF, ASCII 10)
              while Windows uses a carriage return and a line feed (CRLF).
              < http://mathstat.carleton.ca/~help/ma...xplatform.html >

              Perhaps, we could include both the Mac and PC line end characters in
              the same one liner.

              I tried the following one liner and it seems to work on IE 5.0 on
              Windows 98 and IE 5.2 on MacOS 10.2.6.

              Curiously enough, I had to add more HTML tags to get this line to work
              in IE 5.0 on Windows 98. I had to add the standard header stuff.

              javascript:'<ht ml><head><title >Source.file.li sting<\/title><\/head><body><cod e><ol><li>'+(
              document.docume ntElement||docu ment.body).oute rHTML.replace(
              /&/g,"&amp;").repl ace(
              /</g,"&lt;").repla ce(
              /%20%20/g,"&nbsp;%20"). replace(
              /\r\n/g,"<li>").repla ce(
              /\r/g,"<li>")+'<\/ol><\/code><\/body><\/html>';

              Note: You will probably need to get this all on one line before
              pasting into your browser. The one line version is:

              javascript:'<ht ml><head><title >Source file
              listing<\/title><\/head><body><cod e><ol><li>'+(do cument.document Element||docume nt.body).outerH TML.replace(/&/g,"&amp;").repl ace(/</g,"&lt;").repla ce(/%20%20/g,"&nbsp;%20"). replace(/\r\n/g,"<li>").repla ce(/\r/g,"<li>")+'<\/ol><\/code><\/body><\/html>';


              I guess I will work on an innerHTML version that with all three line
              endings.

              Robert

              Comment

              • Matt Kruse

                #8
                Re: FAQ Questions

                Randy Webb wrote:[color=blue]
                >[/color]
                javascript:'<co de><ol><li>'+(d ocument.documen tElement||docum ent.body).outer H
                TML.replace(/&/g,"&amp;").repl ace(/</g,"&lt;").repla ce(/%20%20/g,"&nbsp;%20"
                ).replace(/\n/g,"<li>")+'<\/ol><\/code>';

                Since IE reports line numbers incorrectly when js files are included in the
                source, it might be cool to go request those js files and include them
                in-line, also. Then the line numbers that IE reports might be more accurate,
                no?

                --
                Matt Kruse



                Comment

                • Randy Webb

                  #9
                  Re: FAQ Questions

                  Matt Kruse wrote:[color=blue]
                  > Randy Webb wrote:
                  >
                  > javascript:'<co de><ol><li>'+(d ocument.documen tElement||docum ent.body).outer H
                  > TML.replace(/&/g,"&amp;").repl ace(/</g,"&lt;").repla ce(/%20%20/g,"&nbsp;%20"
                  > ).replace(/\n/g,"<li>")+'<\/ol><\/code>';
                  >
                  > Since IE reports line numbers incorrectly when js files are included in the
                  > source, it might be cool to go request those js files and include them
                  > in-line, also. Then the line numbers that IE reports might be more accurate,
                  > no?
                  >[/color]


                  This is a start on it, needs some more tweaking.

                  j='';k=document .scripts;for(i= 0;i<k.length;i+ +){if(k[i].src){xmlhttp=
                  new ActiveXObject(" Microsoft.XMLHT TP");xmlhttp.op en("GET",k[i].src,true);
                  xmlhttp.onready statechange=fun ction(){if(xmlh ttp.readyState= =4)
                  {j=j+xmlhttp.re sponseText;}};x mlhttp.send(nul l)}}
                  re=/ /g;
                  s=document.crea teElement("scri pt");s.src=j.re place(re,'\n'); document.body.a ppendChild(s);

                  My IE uses the Microsoft.XMLHT TP; others may need to edit it to be
                  Msxml2.XMLHTTP in the ActiveXObject.

                  As written, its not replacing the expression. Another one of those bugs
                  to get out of it. If I alert it (j.replace(...) ), then the \n is there.
                  But when it appends it, it converts it back <shrug>.

                  Even then, the line numbers are still worthless. Since it is written, at
                  the moment, to append it to the body.

                  I will add it to my list of "crap to do at midnight", to change it so
                  that it inserts the actual text of the external file into the page
                  itself. That might take a little work :)

                  If debugging an external file, I always put it in the document, debug
                  it, then move it back to an external file.

                  --
                  Randy
                  comp.lang.javas cript FAQ - http://jibbering.com/faq

                  Comment

                  • Thomas 'PointedEars' Lahn

                    #10
                    Re: FAQ Questions

                    Robert wrote:
                    [color=blue]
                    > Randy Webb <HikksNotAtHome @aol.com> wrote in message[color=green]
                    >> The only two differences in the two is that the first one numbers the
                    >> lines, which makes it a lot easier to see where a particular line number
                    >> is. The other difference is outerHTML versus innerHTML. Does outerHTML
                    >> work in IE on the MAC?[/color]
                    >
                    > I had to change the \n to \r to get this one line of Javascript to
                    > work on MacOS 10.2.6 for IE 5.2.
                    >
                    > javascript:'<co de><ol><li>'+(
                    > document.docume ntElement||docu ment.body).oute rHTML.replace(
                    > /&/g,"&amp;").repl ace(/</g,"&lt;").repla ce(
                    > /%20%20/g,"&nbsp;%20"). replace(
                    > /\r/g,"<li>")+'<\/ol><\/code>';[/color]

                    Don't use javascript: URIs where you can avoid it. Particularly your
                    example creates invalid HTML.
                    [color=blue]
                    > To mark the end of a line in a text file (...), the MacOS uses a
                    > carriage return (CR, ASCII 13), UNIX uses a line feed (LF, ASCII 10)
                    > while Windows uses a carriage return and a line feed (CRLF).
                    > < http://mathstat.carleton.ca/~help/ma...xplatform.html >
                    >
                    > Perhaps, we could include both the Mac and PC line end characters in
                    > the same one liner.[/color]

                    There is no need for different versions for Mac and PC. Perl Compatible
                    Regular Expressions, as supported by ECMAScript implementations , support
                    alternations:

                    var b = document && (document.docum entElement || document.body);
                    if (typeof b.outerHTML == "string")
                    {
                    alert(
                    b.outerHTML
                    .replace(/&/g,"&amp;")
                    .replace(/</g,"&lt;")
                    .replace(/ /g,"&nbsp; ")
                    .replace(/(\r\n?|\n)/g, "<li>"));
                    }


                    PointedEars
                    --
                    The only thing worse than infinite recursion is infinite recursion.

                    Comment

                    • Matt Kruse

                      #11
                      Re: FAQ Questions

                      Thomas 'PointedEars' Lahn wrote:[color=blue][color=green]
                      >> javascript:'<co de><ol><li>'+(
                      >> document.docume ntElement||docu ment.body).oute rHTML.replace(
                      >> /&/g,"&amp;").repl ace(/</g,"&lt;").repla ce(
                      >> /%20%20/g,"&nbsp;%20"). replace(
                      >> /\r/g,"<li>")+'<\/ol><\/code>';[/color]
                      > Don't use javascript: URIs where you can avoid it. Particularly your
                      > example creates invalid HTML.[/color]

                      How else do you propose to create bookmarklets?
                      Duh.

                      --
                      Matt Kruse



                      Comment

                      • Randy Webb

                        #12
                        Re: FAQ Questions

                        Thomas 'PointedEars' Lahn wrote:[color=blue]
                        > Robert wrote:
                        >
                        >[color=green]
                        >>Randy Webb <HikksNotAtHome @aol.com> wrote in message
                        >>[color=darkred]
                        >>>The only two differences in the two is that the first one numbers the
                        >>>lines, which makes it a lot easier to see where a particular line number
                        >>>is. The other difference is outerHTML versus innerHTML. Does outerHTML
                        >>>work in IE on the MAC?[/color]
                        >>
                        >>I had to change the \n to \r to get this one line of Javascript to
                        >>work on MacOS 10.2.6 for IE 5.2.
                        >>
                        >>javascript:'< code><ol><li>'+ (
                        >> document.docume ntElement||docu ment.body).oute rHTML.replace(
                        >> /&/g,"&amp;").repl ace(/</g,"&lt;").repla ce(
                        >> /%20%20/g,"&nbsp;%20"). replace(
                        >> /\r/g,"<li>")+'<\/ol><\/code>';[/color]
                        >
                        >
                        > Don't use javascript: URIs where you can avoid it. Particularly your
                        > example creates invalid HTML.[/color]

                        If you had bothered to read the entire thread, you would have noticed
                        that it was the creation of a bookmarklet that would number the lines in
                        the source code of a page.

                        [color=blue][color=green]
                        >>To mark the end of a line in a text file (...), the MacOS uses a
                        >>carriage return (CR, ASCII 13), UNIX uses a line feed (LF, ASCII 10)
                        >>while Windows uses a carriage return and a line feed (CRLF).
                        >>< http://mathstat.carleton.ca/~help/ma...xplatform.html >
                        >>
                        >>Perhaps, we could include both the Mac and PC line end characters in
                        >>the same one liner.[/color]
                        >
                        >
                        > There is no need for different versions for Mac and PC. Perl Compatible
                        > Regular Expressions, as supported by ECMAScript implementations , support
                        > alternations:
                        >
                        > var b = document && (document.docum entElement || document.body);
                        > if (typeof b.outerHTML == "string")[/color]

                        Since the bookmarklet is for IE only, that test is not needed.
                        [color=blue]
                        > {
                        > alert(
                        > b.outerHTML
                        > .replace(/&/g,"&amp;")
                        > .replace(/</g,"&lt;")
                        > .replace(/ /g,"&nbsp; ")
                        > .replace(/(\r\n?|\n)/g, "<li>"));
                        > }[/color]

                        That does not do what was needed. Read the thread, then try again.


                        --
                        Randy
                        comp.lang.javas cript FAQ - http://jibbering.com/faq

                        Comment

                        • Thomas 'PointedEars' Lahn

                          #13
                          Re: FAQ Questions

                          Matt Kruse wrote:
                          [color=blue]
                          > Thomas 'PointedEars' Lahn wrote:[color=green][color=darkred]
                          >>> javascript:'<co de><ol><li>'+(
                          >>> document.docume ntElement||docu ment.body).oute rHTML.replace(
                          >>> /&/g,"&amp;").repl ace(/</g,"&lt;").repla ce(
                          >>> /%20%20/g,"&nbsp;%20"). replace(
                          >>> /\r/g,"<li>")+'<\/ol><\/code>';[/color]
                          >> Don't use javascript: URIs where you can avoid it. Particularly your[/color][/color]
                          ^^^^^^^^^^^^^^^ ^^^^^^^[color=blue][color=green]
                          >> example creates invalid HTML.[/color]
                          >
                          > How else do you propose to create bookmarklets?
                          > Duh.[/color]

                          I have marked what is important here for
                          those who have difficulties with reading.


                          PointedEars
                          --
                          Eternal salvation or triple your money back!

                          Comment

                          • Randy Webb

                            #14
                            Re: FAQ Questions

                            Thomas 'PointedEars' Lahn wrote:
                            [color=blue]
                            > Matt Kruse wrote:[color=green]
                            >>Thomas 'PointedEars' Lahn wrote:[color=darkred]
                            >>>>javascript: '<code><ol><li> '+(
                            >>>> document.docume ntElement||docu ment.body).oute rHTML.replace(
                            >>>> /&/g,"&amp;").repl ace(/</g,"&lt;").repla ce(
                            >>>> /%20%20/g,"&nbsp;%20"). replace(
                            >>>> /\r/g,"<li>")+'<\/ol><\/code>';
                            >>>
                            >>>Don't use javascript: URIs where you can avoid it. Particularly your[/color][/color]
                            > ^^^^^^^^^^^^^^^ ^^^^^^^[color=green][color=darkred]
                            >>>example creates invalid HTML.[/color]
                            >>How else do you propose to create bookmarklets?
                            >>Duh.[/color]
                            > I have marked what is important here for
                            > those who have difficulties with reading.[/color]

                            What you missed is the whole topic of this thread, which is bookmarklets
                            and how to come up with a way to make IE easier to debug. Now, if you
                            can come up with a way to use that script, from the address bar, without
                            using a javascript URI, then you might have a case. Until then, please
                            STFU, RTFM, and move on.

                            Normal course of action:

                            1) Open Mouth
                            2) Insert Foot
                            3) Be notified of it
                            4) Remove foot
                            5) Thank the person who notified
                            6) Complain of taste

                            Thomas Lahn's Course of Action:

                            1) Open Mouth
                            2) Insert Foot
                            3) Be notified of it
                            4) Insist it tastes good, insert foot further

                            And he wonders why most think he is anally retentive. Sheesh.

                            --
                            Randy
                            comp.lang.javas cript FAQ - http://jibbering.com/faq

                            Comment

                            Working...