How to save/view JS's output?

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

    How to save/view JS's output?

    I have a script, its outputs are in HTML. It displays perferctly in a
    browser, however when I view source, it gives me the JS scripts, but I want
    to view the HTML output. Is there a way I can view or save output?



  • Martin Honnen

    #2
    Re: How to save/view JS's output?



    Poster wrote:
    [color=blue]
    > I have a script, its outputs are in HTML. It displays perferctly in a
    > browser, however when I view source, it gives me the JS scripts, but I want
    > to view the HTML output. Is there a way I can view or save output?[/color]

    It depends on the browser, if it is IE then you could try with the
    following bookmarklet:
    javascript: var source = ''; if (document.docum entElement && (source =
    document.docume ntElement.outer HTML)) { var sourceWin = window.open('',
    'sourceWin'); sourceWin.docum ent.open('text/plain');
    sourceWin.docum ent.write(sourc e); sourceWin.docum ent.close(); } void 0

    With Mozilla or Netscape 7.1 you can use Ctrl-a and view selection
    source or you can use the DOM inspector, both ways you should be able to
    see the current document.

    --

    Martin Honnen


    Comment

    • Poster

      #3
      Re: How to save/view JS's output?

      > Poster wrote:[color=blue]
      >[color=green]
      > > I have a script, its outputs are in HTML. It displays perferctly in a
      > > browser, however when I view source, it gives me the JS scripts, but I[/color][/color]
      want[color=blue][color=green]
      > > to view the HTML output. Is there a way I can view or save output?[/color]
      >
      > It depends on the browser, if it is IE then you could try with the
      > following bookmarklet:
      > javascript: var source = ''; if (document.docum entElement && (source =
      > document.docume ntElement.outer HTML)) { var sourceWin = window.open('',
      > 'sourceWin'); sourceWin.docum ent.open('text/plain');
      > sourceWin.docum ent.write(sourc e); sourceWin.docum ent.close(); } void 0
      >
      > With Mozilla or Netscape 7.1 you can use Ctrl-a and view selection
      > source or you can use the DOM inspector, both ways you should be able to
      > see the current document.
      >[/color]

      I need to hide the original javascript from visitors and only let them see
      the exact HTML ouput from the js file. Here is a sample script:

      <form>
      <input type=button value="Print Multiplication Table"
      onClick="writeM Table()">
      </form>

      <script language="JavaS cript">
      <!--
      function writeMTable() {

      document.writel n(
      '<html><head><t itle>Multiplica tion Table. For printing, choose File |
      Print</title></head>'
      +'<body> This is HTML output'
      )
      document.writel n('</body></html>')
      document.close( )
      }
      //-->

      writeMTable()
      </script>

      The final output is
      <html><head><ti tle>Multiplicat ion Table. For printing, choose File |
      Print</title></head><body> This is HTML output
      </body></html>

      I want my visitor see exact and only
      <html><head><ti tle>Multiplicat ion Table. For printing, choose File |
      Print</title></head><body> This is HTML output
      </body></html>

      And no JS scripts at all.

      It is a Dynamic pages, so I can not simply save file as a static page. Is
      there a way for Perl to call a JS script to make it output? or Let Lynx
      activate JS scripts?


      Comment

      • Ivo

        #4
        Re: How to save/view JS's output?

        "Poster" wrote[color=blue]
        > I need to hide the original javascript from visitors and only let them see
        > the exact HTML ouput from the js file.[/color]

        That is not possible. The script must be downloaded before it can run. What
        secrets are hidden in the script anyway that nobody is allowed to see?
        [color=blue]
        > Here is a sample script:
        >
        > <form>
        > <input type=button value="Print Multiplication Table"
        > onClick="writeM Table()">
        > </form>
        >
        > <script language="JavaS cript">[/color]

        Drop the language. Instead ' type="text/javascript" ' is required.
        [color=blue]
        > <!--[/color]

        Drop the 'hiding' comment. It serve no purpose, none.
        [color=blue]
        > function writeMTable() {
        >
        > document.writel n(
        > '<html><head><t itle>Multiplica tion Table. For printing, choose File |
        > Print</title></head>'
        > +'<body> This is HTML output'
        > )
        > document.writel n('</body></html>')
        > document.close( )
        > }
        > //-->
        >
        > writeMTable()
        > </script>
        >
        > The final output is
        > <html><head><ti tle>Multiplicat ion Table. For printing, choose File |
        > Print</title></head><body> This is HTML output
        > </body></html>
        >
        > I want my visitor see exact and only
        > <html><head><ti tle>Multiplicat ion Table. For printing, choose File |
        > Print</title></head><body> This is HTML output
        > </body></html>
        >
        > And no JS scripts at all.[/color]

        Most visitors will not be interested. Neither in the HTML nor in the
        javascript.
        [color=blue]
        > It is a Dynamic pages, so I can not simply save file as a static page. Is
        > there a way for Perl to call a JS script to make it output? or Let Lynx
        > activate JS scripts?[/color]

        Client-side Javascript is client-side. There is a server-side version on
        some servers. Perl is also server-side. Can't you let Perl do whatever you
        think you need javascript for?
        HTH
        Ivo


        Comment

        • Blue Raja

          #5
          Re: How to save/view JS's output?

          "Poster" <abc@abc.com> wrote in message
          news:%IaNc.1229 454$Ar.272553@t wister01.bloor. is.net.cable.ro gers.com...
          <snip>[color=blue]
          > I need to hide the original javascript from visitors and only let them see
          > the exact HTML ouput from the js file. Here is a sample script:[/color]

          This example could be done server-side using CGI/PHP/ASP/JSP/whatever, thus
          hiding your processing from the client. The output would be straight HTML
          code which wouldn't reveal any processing code tidbits.

          --

          Jason, aka The Blue Raja


          Comment

          • Thomas 'PointedEars' Lahn

            #6
            Re: How to save/view JS's output?

            Poster <abc@abc.com> wrote:
            ^^^^^^^^^^^
            Does ABC, Inc., New York, know that you are abusing their domain to
            falsify your sender address and thus perpetrate a violation of both
            Internet/Usenet standards and the Consumer Terms and Conditions of
            your service provider, Rogers Communications, Inc., Markham, CA?

            <http://www.interhack.n et/pubs/munging-harmful/>
            [color=blue][color=green]
            >> Poster wrote:
            >>[color=darkred]
            >> > I have a script, its outputs are in HTML. It displays perferctly in a
            >> > browser, however when I view source, it gives me the JS scripts, but I[/color][/color]
            > want[/color]
            ^^^^^^
            Please visit <http://insideoe.tomste rdam.com/> to get informed
            about the flaws of your software and how they can be circumvented.
            [color=blue]
            > [...]
            > I need to hide the original javascript from visitors and only let them see
            > the exact HTML ouput from the js file. [...][/color]

            Are you sure you know about the diversity of the Web, its users and
            their software?
            [color=blue]
            > Here is a sample script:
            >
            > <form>
            > <input type=button value="Print Multiplication Table"
            > onClick="writeM Table()">
            > </form>
            >
            > <script language="JavaS cript">[/color]

            This should read

            <script type="text/javascript">

            Ask Google (Groups).
            [color=blue]
            > <!--[/color]

            Remove that, it is obsolete.
            [color=blue]
            > function writeMTable() {
            >
            > document.writel n(
            > '<html><head><t itle>Multiplica tion Table. For printing, choose File |
            > Print</title></head>'
            > +'<body> This is HTML output'
            > )
            > document.writel n('</body></html>')[/color]

            When using ETAGO delimiters within CDATA, especially when writing HTML close
            tags within "script" elements, ETAGOs (and close tags in general for buggy
            clients) must be escaped to prevent premature end of the parent element:

            document.write( '<\/body><\/html>');

            Besides, the markup you are generating and generating with is both far from
            Valid HTML.

            <http://validator.w3.or g/>
            [color=blue]
            > document.close( )
            > }[/color]
            [color=blue]
            > //-->[/color]

            You can then safely omit this, too.
            [color=blue]
            > writeMTable()
            > </script>
            >
            > [...]
            > It is a Dynamic pages, so I can not simply save file as a static page. Is
            > there a way for Perl to call a JS script to make it output?[/color]

            For either client-side Perl or server-side JS, maybe.
            [color=blue]
            > or Let Lynx activate JS scripts?[/color]

            No, and there are plenty of users who have UAs with JS support but have the
            feature disabled or restricted. You see that generating whole documents
            with client-side scripting (whatever language is used) is not a viable
            solution on the Web.


            PointedEars

            Comment

            Working...