-1

is there a possibility to show generated HTML from Javascript (not PHP o.c.) e.g. I create a table with JS and would like to display the HTML code created by adding strings to the innerHTML property.

The browser only shows the JS scripts and empty table structs and I would like to know if there are websites / programs which can show the plain result

Alexx01
  • 13
  • 1
  • 2
    Do you mean when you right click and view source? Have you looked into the browser's developer's tools to inspect the document? – j08691 May 18 '15 at 20:30
  • It's hard to figure out what you're asking. Can you show an example via jsfiddle of what you're trying to do? – lxe May 18 '15 at 20:30
  • This question needs some serious clarification of what you actually want. – DBS May 18 '15 at 20:30
  • Questions asking for recommendations for off-site resources are considered off topic. If you can reword this to fit the (guidelines at Software Recommendations)[http://meta.softwarerecs.stackexchange.com/questions/356/what-is-required-for-an-answer-to-be-high-quality] you can try asking there. Be sure to check that it hasn't already been asked. – BSMP May 18 '15 at 20:41

2 Answers2

1

I think I know what you're asking; not sure where the comment confusion is from.

Most browsers have a separate "View Source" menu action that will show the basic HTML coming from the server, sans any JavaScript processing. Usually, on Windows the keyboard combination is Ctrl-U. On mac it'll likely be under View>.

EDIT: Although given that re-reading the question gives me some confusion...it's possible you want the opposite. The F12 key (Developer Tools) lets you view the HTML after JS has had its way with it.

Katana314
  • 8,429
  • 2
  • 28
  • 36
  • Using the Developer Tools! Thank you, this was the thing I asked for, a way to show the interpreted result (the outcome of the JS script) – Alexx01 May 20 '15 at 16:30
0

JavaScript doesn't generate HTML, unlike php. It (normally) runs directly on the client, in the web browser, and the code you write interacts directly with a representation of the document content. If you create a table in JS you don't "write HTML" - you dynamically create nodes in the DOM, and add HTML elements, and the content of those elements. Having said all that, you can basically add straight HTML to your document if you really want to, but there's not much point. If you want to do that you can just send it direct from the server, via php or anything else.

If you run your JavaScript debugger in your dev tools (Firebug, etc) and look through the document elements (in other words, the HTML) you can generally get some idea of what you've added. You could see HTML for your table, for example. Stand-alone programs aren't good for this, because they need to run your JavaScript first. It's very hard to find an HTML to pdf converter, for example, that can cope with a page that runs JS.

EML
  • 9,619
  • 6
  • 46
  • 78