View Full Version : Convert Javascript to html

10-20-2006, 11:07 AM
Is there such a thing? I am trying to convert a javascript code into html based so that my blogger post can take it. There are a lot of html to javascript but not the other way around. Hope someone can help. I would really appreciate it.

10-20-2006, 05:06 PM
it depends wot u r trying to convert perhaps you could show your code and explain wot u r wanting to do with each bit of it.

11-05-2006, 05:34 AM
I get a code <script> </script> and I need to convert that into an <a href> or <iframe>. I am hoping you would be able to help me with this. :)

11-05-2006, 05:59 AM
To show your JavaScript and/or HTML source code:

Save this as js2html.html

<head><title>JavaScript to HTML</title>
<script type="text/javascript">
function encode(){
var s = document.getElementById('source');
var txt = s.value;
txt = txt.replace(/[&]/g,'&amp;');
txt = txt.replace(/[<]/g,'&lt;');
txt = txt.replace(/[>]/g,'&gt;');
s.value = txt;
<button onclick="encode()">Convert to HTML</button><br />
<textarea id="source" style="width:90%;height:400px"></textarea>

Open js2html.html with your web browser.
Paste in the HTML and/or Javascript code you wish to convert.
Click the convert button ONLY ONCE.
copy and paste the result into the blog.

You may desire to place the output between <pre> and </pre> tags in order to preserve the formatting of the code.

If your aim is to get the script to run on your blog, and you're getting <script> tags then you are not allowed to post JavaScript to your blog. The blog is doing exactly what the code above does... Get a better blog.