How to save Content/text of a Web page by forcing Save-as option

Source: Internet
Author: User

I would like to know what would is the best-of-the-contents from a Web page. I mean to force save-as option by clicking a link or button. I often found that JavaScript would not is an option because it's only working for IE, so I thought the it would be Easie R because JavaScript is client-side based.

Now, I thought maybe there is a-to-use PHP when creating a form that would redirect it over a server site query to Retu RN and force the SAVE-AS option. My main goal is make it possible to save the privacy terms. I would like to avoid using fpdf. If There is someone the Who could tell how to solve this I would really appreciate it.

UPDATE:

Okay to explain what I like to reach:

Imagine you has a simple webpage with some privacy policy text and nothing else. At the top of the page there are the options. First would be the print option like:

<a href="Javascript:print ()">Print</a>

Second should is something like:

<a href="Javascript:saveas ()">Save</a>

So if you'll press the link the Save-as dialog pops up and you can download the content or even page to get the P Rivacy policy for your own.

Hope it'll be a clear now. Sorry.


If you want to force a download without JavaScript, simply open the content in a new tab by adding a unknown target.

Example Code

<a href="Whatever.com/download.zip" Target="_new">Click Me</a>

This works only if the page offers a download, otherwise the content gets displayed. Need a simple php-file, which gets the content from the page and customizes the header.

<?php$content=file_get_contents($_get["DownloadURL"]);Header("Content-type:application/octet-stream");Echo $content;?>

UPDATE

As a more detailed example for your edited informations, you could probably does this:

Php-file "Reader.php"

<?php$content=file_get_contents($_get["DownloadURL"]);Header("Content-type:application/octet-stream");Echo $content;?>

HTML on page "test.html"

<a href="Reader.php?downloadurl=http://yourwebsite.com/test.html" Target="_new">Save website</a>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.