0

I have a web page with few tabs. All tabs have same data but in different format. The page has a copy to clipboard feature which copies the contents of the active tab to clipboard. Similarly we need to have a save as text file option which copies contents of the active tab alone by prompting use for selecting a location and then ssving it. I checked a few alternatives like use of execcommand, but not sure whats best way to do the same.

Thanks in advance.

1 Answer 1

1

You could accomplish this by posting the contents to a server page which would basically echo the contents back in such a way as to provoke the browser into launching a "what do you want to do with this?" dialog where one option is "Save to disk." If there's a way to get the client to go straight to the "Save to disk" option, all the better.

I've found that different browsers deal with this in different ways - some look at the extension of the server page, and some at the HTTP content-type.

For example, I had a page, call it server.cgi, which would produce a zip file and I think IE defaulted the file name in the "Save As" dialog to server.cgi. By changing the server file to server.zip, the prompt did the right thing. I think Firefox responded to the content-type header.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.