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 2 of 2

Thread: Load HTML file

  1. #1
    New to the CF scene
    Join Date
    Jun 2012
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Load HTML file

    I want to load a html file with click event...(given html file should be loaded with clicking on special button)
    how can i do that with javscript? any solution?
    thanks in advance

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,730
    Thanks
    202
    Thanked 2,508 Times in 2,486 Posts
    Quote Originally Posted by soheil View Post
    I want to load a html file with click event...(given html file should be loaded with clicking on special button)
    how can i do that with javscript? any solution?
    thanks in advance
    Use an <iframe>

    Code:
    <div id = "container"  style="display:none">
    <iframe id = "frame1" src = "" width="100%" height="300"></iframe> 
    </div>
    
    <input type ="button" value = "Load HTML page" onclick = "showIt()">
    
    <script type = "text/javascript">
    function showIt() {
    document.getElementById("container").style.display="block";
    document.getElementById("frame1").src = 'http://www.javascriptkit.com' 
    }
    
    </script>
    or Ajax ...

    or jQuery ...

    All advice is supplied packaged by intellectual weight, and not by volume. Contents may settle slightly in transit.
    Last edited by Philip M; 06-29-2012 at 07:28 PM.

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.


  •  

    Posting Permissions

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