Feed Electron's webview with HTML contained in a string - electron

I want to embed an "HTML viewer" inside of my Electron app, which would be fed with HTML contained in a string. My application automatically generates HTML code, which I want to visualize rendered as it would be displayed in a web browser.
I have seen there is a component called <webview> but it loads the HTML content from an external site via URI.
Is it possible to feed this <webview> component (or any other) with HTML from a simple string to achieve my goal?

Check this in electron repository
https://github.com/electron/electron/issues/1146
You can go with data uri, if you don't need JavaScript.
If you need JavaScript, there is a workaround. You can save the html string as a html file and load the html file in electron
Once the window is closed, you can delete the html file

Related

How to upload a page to web and shows the page when url is given in browser?

I have designed a page using photoshop and illustrator for my product.Actually its the first page of our website, construction is not over yet.But I want to upload that one page to web now just for publicity.The thing is that i want to get that page open when the user types url in browser.
So, What i have to do to upload page to web and shows my page whenever the url is written in browser??Please help...
Is your page still in an image format or have you converted it to HTML?
If you have converted to HTML, upload it to your server and give the link of the HTML to users to check out the page.
It's not clear what your problem is but:
Register a domain with a provider
Name your html file index.html and upload it to the root folder of your web space.

Why are .html file parsed rather than compiled when open them in browser such as Safari?

Why are .html file parsed rather than compiled when open them in browser such as Safari? From the internet, I learned that parser is a component of a compiler. People say .html is parsed to a web page, but why not compiled to a web page? .html file contains code that needed to be compiled so that it becomes a webpage, right?
Some possible reasons: Maybe when we say something is compiled, it has to be compiled into machine language but .html does not?
HTML does not get compiled - it simply describes how the website should be rendered.
And that is then interpreted by the browser - it doesn't end up as machine code.
It's like a map or blue prints telling the browser's rendering engine how to build the website.
The W3C defines how these "plans" should be written and the browser vendor should make sure they interpret the plans in the correct way.
Developers should make sure they use the HTML elements properly so that the HTML files make sense and the browser can construct the web page properly.
What difference does it make? You have not described a problem you are having.
The parsing of HTML is application-dependent. Each browser/parser decides how to do it.
HTML however must be dynamically modifiable. Since HTML is not executed, it is not clear what the difference is between compiling and interpreting but typically compiled code can't be easily modified.
JavaScript is by definition interpreted.

Google Sites HTML removes ID attribute

I am trying to use JQuery's accordion on a Google Sites page.
When trying to assign an ID or class to, say, a element, Google Site's HTML editor removes those attributes.
So, for instance, I type and then click Update. Upon returning to the HTML editor, that line of code reads simply .
You can add Jquery on Google Sites via App Script ( HTML Services )
https://developers.google.com/apps-script/guides/html/restrictions#jquery_and_jquery_ui

How to retrieve HTML representation of components?

I would like to output HTML codes of my vaadin's components at my console. I didn't find any methods for this . Can it be possible ?
It is not possible to retrieve component's generated HTML with Vaadin's server-side programming mode.
If you really need to do it, you could write your own extension what transfers component's generated HTML from browser to server after it's rendered. Writing your extension means the you need to it with GWT (GWT Web Toolkit, formerly Google Web Toolkit).

Render external html page with dependancies (resources)

I have an ASP.NET MVC3 application. In my application, I need to be able to render external HTML pages. These HTML pages are stored in a simple file structure, with images, CSS and JS files stored in folders. Basically opening the HTML file will render the page as it should be rendered. What I want is to be able to render this page programatically.
So far, I have tried stuff like this:
Response.WriteFile(path)
return new FilePathResult("~/Path", "text/html");
The problem is that the resources (images, CSS and JS files) do not get loaded, since I only load the html source.
What can I do to be able to correctly render the html file with the other included files?
P.S.: I know that this functionality can be a security hole in my application. Thanks!
Edit: As Darin pointed out, I can use an iframe to place the rendered HTML page in my view. This is what I am currently using, but I want to implement a more secure solution, a solution that wouldn't allow access to the actual HTML page.
What can I do to be able to correctly render the html file with the other included files?
You could use an iframe:
<iframe src="/somepage.html"></iframe>
The return new FilePathResult("~/Path", "text/html"); should also work, it's just that the static resources referenced in this HTML page (CSS, javascript, images, ...) need to be relative to the current url or absolute urls (which is more difficult if they are static HTML).

Resources