Save page into file

P

Prakashsir

I have desgined script to show div at runtime. Now I want to copy that
newly created div and/or to save in normal html file so that i can see
later.

1. When I select all the content or view its source, it does not shows
the newly created div.
2. My script is working in IE but not working in Mozilla firefox.
(I want to work in Mozilla, b'cause when we select all the content with
new div and can save with that also.)
3. I want to save this loaded page using javascript.

Please help me, its urgent...!

Prakash
 
J

Jc

Prakashsir said:
I have desgined script to show div at runtime. Now I want to copy that
newly created div and/or to save in normal html file so that i can see
later.

1. When I select all the content or view its source, it does not shows
the newly created div.
2. My script is working in IE but not working in Mozilla firefox.
(I want to work in Mozilla, b'cause when we select all the content with
new div and can save with that also.)
3. I want to save this loaded page using javascript.

Please help me, its urgent...!

Prakash

I believe you can save the result of script changes to HTML in IE by
changing the "Save as type" to "Web Page, HTML only" from the Save As
option under the File menu.

This should allow you to save your page as an HTML file with the DIV
included.

There are many differences between IE and Mozilla, check out the "W3C
DOM Compatibility Tables" at http://www.quirksmode.org/.
 
I

Ivo

I have desgined script to show div at runtime. Now I want to copy that
newly created div and/or to save in normal html file so that i can see
later.

1. When I select all the content or view its source, it does not shows
the newly created div.
2. My script is working in IE but not working in Mozilla firefox.
(I want to work in Mozilla, b'cause when we select all the content with
new div and can save with that also.)
3. I want to save this loaded page using javascript.

There is no standard way to do this, it would really be better to rethink
your needs here, but IE/Win has the execCommand( 'SaveAs' ) to save an
arbitrary string of text (for example the outerHTML of your div or the whole
body) to the user's file system.

See for a demonstration, among others:
<URL: http://4umi.com/web/javascript/filewrite.htm >

WIth an ActiveXobject you would have even some more control over the format
and filename, but that would narrow the user base even further.
hth
ivo
 
R

RobG

ASM said:
sorry

you CAN'T save anything by JS

No, but you can view/save the modified source. Copy/paste the code
below into the address bar, watch for wrapping it needs to be a single
line without returns:

javascript:CODE=window.open('','CODE','height=700,width=800');
CODE.document.write('<FORM NAME="SPAM"><TEXTAREA NAME="SRC" ROWS=45
COLS=82></TEXTAREA></FORM>');
CODE.document.SPAM.SRC.value=document.documentElement.innerHTML;
CODE.document.close();void 0;


Save it as a bookmark if you like!
 
A

ASM

RobG said:
you can view/save the modified source. Copy/paste the code
below into the address bar, watch for wrapping it needs to be a single
line without returns:

javascript:CODE=window.open('','CODE','height=700,width=800');
CODE.document.write('<FORM NAME="SPAM"><TEXTAREA NAME="SRC" ROWS=45
COLS=82></TEXTAREA></FORM>');
CODE.document.SPAM.SRC.value=document.documentElement.innerHTML;
CODE.document.close();void 0;


Save it as a bookmark if you like!

what is : documentElement
or ...
how do you pass this argument to this bookmark ?
 
I

Ivo

"ASM" wrote
what is : documentElement
or ...
how do you pass this argument to this bookmark ?
I believe it is all meant to be on one line. The innerHTML could also be
written directly between writing the textarea tags. documentElement is a
reference to the root node of the document.

This is another 'View Generated Source' bookmarklet, with linenumbers:

javascript:'<code><ol><li>'+(document.documentElement||document.body).outerH
TML.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/%20%20/g,"&nbsp;%20"
).replace(/\n/g,"<li>")+'<\/ol><\/code>';

hth
ivo
 
R

RobG

Ivo said:
"ASM" wrote

To ASM:

create a new bookmark, then edit it. Replace the URL in the bookmark
with the script.
I believe it is all meant to be on one line. The innerHTML could also be
written directly between writing the textarea tags. documentElement is a
reference to the root node of the document.

This is another 'View Generated Source' bookmarklet, with linenumbers:

javascript:'<code><ol><li>'+(document.documentElement||document.body).outerH
TML.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/%20%20/g,"&nbsp;%20"
).replace(/\n/g,"<li>")+'<\/ol><\/code>';

The use of outerHTML makes it less browser-friendly - but it works in
IE 5.2 where the one I posted didn't.
 
A

alu

"ASM" wrote
That method is IE/Win only, and allows you to write either .txt or .html
files only.


You could try writing
document.body.innerHTML
into a new window and printing from there. Seems to work in IE/Win &
Firefox.
-alu
 

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
473,769
Messages
2,569,582
Members
45,069
Latest member
SimplyleanKetoReviews

Latest Threads

Top