How to save/view JS's output?

P

Poster

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?
 
M

Martin Honnen

Poster said:
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?

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.
 
P

Poster

Poster said:
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.

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?
 
I

Ivo

I need to hide the original javascript from visitors and only let them see
the exact HTML ouput from the js file.

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?
Here is a sample script:

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

<script language="JavaScript">

Drop the language. Instead ' type="text/javascript" ' is required.

Drop the 'hiding' comment. It serve no purpose, none.
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.

Most visitors will not be interested. Neither in the HTML nor in the
javascript.
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?

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
 
B

Blue Raja

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:

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.
 
T

Thomas 'PointedEars' Lahn

^^^^^^^^^^^
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?

^^^^^^

[...]
I need to hide the original javascript from visitors and only let them see
the exact HTML ouput from the js file. [...]

Are you sure you know about the diversity of the Web, its users and
their software?
Here is a sample script:

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

<script language="JavaScript">

This should read

<script type="text/javascript">

Ask Google (Groups).

Remove that, it is obsolete.
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>')

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.

document.close()
}

You can then safely omit this, too.
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?

For either client-side Perl or server-side JS, maybe.
or Let Lynx activate JS scripts?

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,433
Messages
2,571,683
Members
48,796
Latest member
Greg L.

Latest Threads

Top