Connecting Tech Pros Worldwide Help | Site Map

How to save/view JS's output?

Poster
Guest
 
Posts: n/a
#1: Jul 23 '05
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
Guest
 
Posts: n/a
#2: Jul 23 '05

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.documentElement && (source =
document.documentElement.outerHTML)) { var sourceWin = window.open('',
'sourceWin'); sourceWin.document.open('text/plain');
sourceWin.document.write(source); sourceWin.document.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
http://JavaScript.FAQTs.com/

Poster
Guest
 
Posts: n/a
#3: Jul 23 '05

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.documentElement && (source =
> document.documentElement.outerHTML)) { var sourceWin = window.open('',
> 'sourceWin'); sourceWin.document.open('text/plain');
> sourceWin.document.write(source); sourceWin.document.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="writeMTable()">
</form>

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

document.writeln(
'<html><head><title>Multiplication Table. For printing, choose File |
Print</title></head>'
+'<body> This is HTML output'
)
document.writeln('</body></html>')
document.close()
}
//-->

writeMTable()
</script>

The final output is
<html><head><title>Multiplication 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><title>Multiplication 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?


Ivo
Guest
 
Posts: n/a
#4: Jul 23 '05

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="writeMTable()">
> </form>
>
> <script language="JavaScript">[/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.writeln(
> '<html><head><title>Multiplication Table. For printing, choose File |
> Print</title></head>'
> +'<body> This is HTML output'
> )
> document.writeln('</body></html>')
> document.close()
> }
> //-->
>
> writeMTable()
> </script>
>
> The final output is
> <html><head><title>Multiplication 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><title>Multiplication 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


Blue Raja
Guest
 
Posts: n/a
#5: Jul 23 '05

re: How to save/view JS's output?


"Poster" <abc@abc.com> wrote in message
news:%IaNc.1229454$Ar.272553@twister01.bloor.is.ne t.cable.rogers.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


Thomas 'PointedEars' Lahn
Guest
 
Posts: n/a
#6: Jul 23 '05

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.net/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.tomsterdam.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="writeMTable()">
> </form>
>
> <script language="JavaScript">[/color]

This should read

<script type="text/javascript">

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

Remove that, it is obsolete.
[color=blue]
> function writeMTable() {
>
> document.writeln(
> '<html><head><title>Multiplication Table. For printing, choose File |
> Print</title></head>'
> +'<body> This is HTML output'
> )
> document.writeln('</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.org/>
[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
Closed Thread