Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Jul 2006
    Location
    British Columbia Canada
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Convert Javascript to html

    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.

  • #2
    Regular Coder mic2100's Avatar
    Join Date
    Feb 2006
    Location
    Scunthorpe
    Posts
    562
    Thanks
    15
    Thanked 28 Times in 27 Posts
    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.

  • #3
    New to the CF scene
    Join Date
    Jul 2006
    Location
    British Columbia Canada
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Javascript to html

    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.

  • #4
    Regular Coder
    Join Date
    May 2005
    Posts
    142
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Cool You need to replace the <, > and &...

    To show your JavaScript and/or HTML source code:

    Save this as js2html.html
    PHP Code:
    <html>
    <
    head><title>JavaScript to HTML</title>
    <
    script type="text/javascript">
    function 
    encode(){
        var 
    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;
    }
    </script>
    </head>
    <body>
    <button onclick="encode()">Convert to HTML</button><br />
    <textarea id="source" style="width:90%;height:400px"></textarea>
    </body></html> 
    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.
    Last edited by VortexCortex; 11-05-2006 at 06:12 AM. Reason: added instructions


  •  

    LinkBacks (?)


    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •