简体   繁体   中英

Download contents of a div as HTML

I'm building a html webpage and wondered if it's possible to have a link that when clicked will download the html contents of a specific div (on the same page) as a .html or .zip file.

I've searched for javascript or jquery examples but can't seem to find one that works cross browser. I tried the HTML5 download attribute but that doesn't work for older browsers/IE.

Thanks

Here you have a table with the browsers and thier compatibility with attribute download that Mike posted you in a comment: http://caniuse.com/download

And the actual tag with attribute is (just for sure you typing it right):

<a href="your_path_to_file" download>Download Me!</a>

-- it will work only in firefox, chrome and opera as it is in a table.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM