PDA

View Full Version : how i can SAVEAS a web page programmaticaly with html5/js



lse123
12-08-2012, 10:01 AM
how i can SAVEAS a web page programmaticaly with html5/js? If only an image on page it will save image instead?

Beverleyh
12-08-2012, 01:55 PM
What do you mean?

If its an HTML5 web page that you've made, in Notepad or Dreamweaver etc, you just save it on your computer with an htm/html extension. The js can be internal, or if its an external file, save it with the js extension.

If you want to save/download a live HTML5 web page, you go to the browser's tool or options menu and there'll be an option to save the web page. When prompted, choose the option for saving as a 'complete' web page and then it, and all of its resources (external js and images, etc) will be saved to your computer too.

I think IE (9 for sure) will sometimes save the web page with a different DOCTYPE - it will put a transitional one above the HTML5 DOCTYPE - but just edit the saved web page to take the extra one out.

In either case, if the web page has a different DOCTYPE to begin with, you would need to convert it to include HTML5 tags/ HTML5 DOCTYPE

lse123
12-08-2012, 03:16 PM
like on file upload there isn't file save dialog? save in client not localStorage a whole page or image or another web page file loaded?

Beverleyh
12-08-2012, 04:02 PM
Sorry, I really have no idea what you're talking about

What file upload are you referring to? Is it a file upload feature on your web host? Or are you describing something on your FTP client?

Please try to use complete sentences and explain what you're trying to do from the very beginning. Please state your intentions, what you're trying to accomplish and also software, tools or scripts you're using.

lse123
12-08-2012, 04:53 PM
I mean like input tag of type file, the dialog appear when browse pressed...

same appear with a event handler but save as dialog (not browse dialog) to save the image or canvas to hdd or mobile ram, well?

Beverleyh
12-08-2012, 05:08 PM
Are you referring to a CMS to save updates/changes made to a web page?

traq
12-08-2012, 05:26 PM
lse123,

You need to explain your questions more clearly.

For example, your original post would seem to indicate that you want to save an entire webpage (and its resources, images, scripts, etc.) to your computer. However, subsequent posts seem to contradict that.

Please describe, specifically, what you're working with and what you want to accomplish. If you can find examples of the functionality you want on other websites, please share those URLs. Situational examples, or even sketches, may help also.

It's "okay" if your question is long, as long as that helps us figure things out.

If you don't mind my asking, is English your native language? If not, there might be someone on the forum that can help you translate. You might also post your question in your native language, alongside English, so we can try to help translate.

lse123
12-08-2012, 05:34 PM
I have a canvas and I want: pressing a button or link appear the saveas dialog to save this canvas as png without leave page, just like firefox dialog "Save Image As" (right click) menu option, well?

I saw some commands by searching but did not make it...



function saveAs(f) {
if(typeof document.execCommand == "object") {
document.execCommand("SaveAs",true,f);
}
else {
alert("From the File Menu, Select Save As ... to Save.")
}
}

lse123
12-08-2012, 07:49 PM
also may save some localStorage data as txt file in PC or mobi device, ...?

traq
12-08-2012, 09:40 PM
I have a canvas and I want: pressing a button or link appear the saveas dialog to save this canvas as png without leave page, just like firefox dialog "Save Image As" (right click) menu option, well?

This tutorial (http://www.html5canvastutorials.com/advanced/html5-canvas-save-drawing-as-an-image/) describes how to do exactly that.

Note that this is the second search result for "save html canvas as png (http://lmgtfy.com/?q=save+html+canvas+as+png)". We are not Google - please do your own research to start with. If you have specific problems making code work, or if you've done your research and can't find anything, we're happy to help.

lse123
12-09-2012, 08:55 AM
this requires Right click is anything of kind of button click that, produce a save as dialog (not right click)??? also may save some localStorage data as txt file in PC or mobi device, ...?

lse123
12-09-2012, 12:28 PM
i TRIED USE
http://www.w3.org/TR/file-writer-api/
BUT FAILED
also may save some localStorage data as txt file in PC or mobi device, ...?
THIS may all localStorage processed to txt file.
this by pressing a button. same i want for image save (press button)... not right click.

traq
12-09-2012, 04:42 PM
AFAIK, you can't make a "save as" button via JavaScript - I may be wrong, but I've never seen it. The filewriter API may allow that, but I don't know how well supported it is.

The alternative, if you really don't want to right-click, might be to use js to submit the canvas data to you server, and then offer a "download" button. Seems like an over-complication to me, though.

lse123
12-09-2012, 09:43 PM
download button includes save as dialog in client/browser
? how?

bernie1227
12-09-2012, 11:43 PM
In short, there is now crossbrowser event associated with saveas. Basically, there's no easy way, and the hard ways may not work either. The best I've seen in terms of this question was the top answer here (http://stackoverflow.com/questions/399486/open-the-save-image-dialog-using-jquery-javascript), which uses a rather complicated method. Frankly, it'd be much easier if you were just to tell us why you don't want to use right click, so that we can think of workarounds that are perfectly viable. You're welcome to try the solution in the linked thread, but there may be better workarounds than a button that forces a save as.

traq
12-09-2012, 11:57 PM
download button includes save as dialog in client/browser
? how?

You're back to using vague, incomplete statements/questions.

This prevents us from helping you.

Please use complete sentences and clearly explain your questions when posting.

ajfmrf
12-10-2012, 12:58 AM
I have never seen such unclear,or precise questions.I wish you knew how to explain what you are asking because it hurts to read these posts of people trying to help you but unable to understand just what you are asking.

Please be crystal clear as to what you want to do.Then maybe,just maybe someone can help