Featured post
jquery - how to save dynamically changed ( byjquery ) html DOM? -
i got nice layout generator using jquery dynamic forms, , jquery ui features change number of used elements, css properties etc. looks great there 1 problem presentation of current result. save generated html dom , parse somehow ( delete hidden elements dom tree etc ). ideas how save current (modified) html + css?
solution using jquery follows:
step 1:
convert whole (modified) html string representation:
var html = $('html').clone(); var htmlstring = html.html();
step 2:
base64 encode htmlstring , put datauri inside hyperlink:
var datauri = "data:text/html;charset=utf-8;base64," + $base64.encode(htmlstring); $("body").append("<a href='" + datauri + "'>save</a>");
note: i'm using library base64 encoding above: http://hpyer.cn/codes/jquery-plugin-base64-encode-and-decode
step 3:
right-click on 'save' link dynamically created above , choose "save as" browser's context menu. modified html file saved new html document on local filesystem.
i've tried before , works. hope work , others well. solution works without server-side technology, nor require flash, java applets, active-x controls, xpcom or proprietary client-side technology. thing required (modern) browser supports data-uris.
- Get link
- X
- Other Apps
Comments
Post a Comment