on page have referenced external css file so:
<link rel="stylesheet" href="css/general.css"> this applies style various html elements.
if send html content server (to made pdf):
$.ajax({ url: 'process.php', type: 'post', data: { html: $("html").html() }, success: function (data) { } }); will associated css stored also? or not since not inline css?
if not, how can overcome all website content gets sent server?
here jquery code takes external css , inlines it, may helpful:
$("link").each(function(i, el) { var jel = $(el); var href = jel.attr("href"); if(href && jel.attr("rel") === "stylesheet") { $.when($.get(href)) .done(function(response) { $('<style />').text(response).appendto($('head')); jel.remove(); }); } }); this code go through stylesheet links in document head , inline each of them. capture css long css files don't have external dependencies, such images, fonts, or imports.
please keep in mind it's asynchronous, if want know when it's done, need give callback when assets retrieved.
Comments
Post a Comment