Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to include all resources into one html file?

Tags:

html

c#

is there any c# library or any free tool which can convert a html file with many referenced resources into a one "all-in-one" html file?

The main task is to have only one file, it means I need to include

  1. Javascript external files - this will probably mean replace all 'script' tags with 'src' attribute by 'script' tags with content read from referenced file.
  2. Images - replace src="picture.png" with data uri - something like src="data:image/png;base64,encodedContent..."
  3. CSS files
  4. may be i forgot something :)

This HTML file must be readable in all browsers, that's why I cannot use MHT file format (unreadable on Safari, iPad...)

like image 431
cartas Avatar asked Apr 30 '12 13:04

cartas


People also ask

How do I display the content of one HTML page in another?

You could use an <iframe> in order to display an external webpage within your webpage. Just place the url of the webpage that you want to display inside the quotes of the src attribute. Show activity on this post. Either you use an iframe or you load the site via AJAX into a div (e.g. using jQuerys load() method).

How to include HTML in other HTML documents?

The basic element you can use to include HTML in other HTML documents is the HTML link. The link element has an opening and a closing tag. This is important to know because inside the opening tag, you are supposed to add specific HTML attributes that are going to create the link.

How to add a resource reference in HTML?

How to add a resource reference in HTML? Use the <link> tag to add a resource reference. The HTML <link> tag is used for defining a link to an external document. It is placed in the <head> section of the document. Defines the character encoding of the linked document. Specifies the URL of the resource document.

What is the difference between HTML code and include tag?

Whereas in first one html code, we only include a script file which we get from web and the link is specified in this article. After this is body tag, here we use include tag, which is a paired tag. in src attribute of include you have to give the location with name and extension.

How do I include HTML in a 404 page?

Including HTML is done by using a w3-include-html attribute: HTML includes are done by JavaScript. if (this.status == 404) {elmnt.innerHTML = "Page not found.";}


1 Answers

You can use HTML Agility Pack to go read/write the html document. HTML Agility supports XPath so you can get a list of nodes you want to modify.

Using this, changing the attribute value of image tags should be easy. You can also get a list of external js references, read them and then update the script tag accordingly.

like image 60
MWS Avatar answered Nov 03 '22 13:11

MWS