Problem Loading Page in Specific Div

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • shaikhanu
    New Member
    • Aug 2010
    • 1

    #1

    Problem Loading Page in Specific Div

    Main.html
    =========
    Code:
    <html>
    <head><title>Main Page</title></head>
    <script type="text/javascript" src=GetPage.js>
    </script>
    <body>
    <form method=get onsubmit="load('History.html','GetDiv'); return false;">
    <input type="text" name="quota" value="">
    </form>
    
    <div id="GetDiv">
    
    </div>
    </body>
    </html>


    GetPage.js
    ===========
    Code:
    function ahah(url,target) {
        document.getElementById(target).innerHTML = 'loading data...';
        if (window.XMLHttpRequest) {
            req = new XMLHttpRequest();
            req.onreadystatechange = function() {ahahDone(target);};
            req.open("GET", url, true);
            req.send(null);
        } else if (window.ActiveXObject) {
            req = new ActiveXObject("Microsoft.XMLHTTP");
            if (req) {
                req.onreadystatechange = function() {ahahDone(target);};
                req.open("GET", url, true);
                req.send();
            }
        }
    } 
    
    
    function ahahDone(target) {
       // only if req is "loaded"
       if (req.readyState == 4) {
           // only if "OK"
           if (req.status == 200 || req.status == 304) {
               results = req.responseText;
               document.getElementById(target).innerHTML = results;
           } else {
               document.getElementById(target).innerHTML="ahah error:\n" +
                   req.statusText;
           }
       }
    }
    
    
    function load(name,div) {
    
    ahah(name,div);
    return false;
    
    }

    History.html
    =============
    Code:
    <html>
    <head><title>History Page</title></head>
    <body>
    <div id="History">
    <p> History Page </p>
    <SCRIPT language="javascript">
    document.write("History Page");
    </SCRIPT>
    </div>
    </body>
    </html>

    The Script works great. i am able to get the History.HTML Loaded perfectly under Div=GetDiv but i am unable to execute or run the Script under history.html page when its loaded under div.

    Script on history.html page works well if opened in a new browser i.e. http://localhost/history.html

    My main idea is to execute the script under history page and display it under GetDiv

    Please Help !!!
    Last edited by Dormilich; Aug 29 '10, 07:33 AM. Reason: Please use [code] tags when posting code
Working...