Asynchronously load scripts using iframe
The script that requests another page asynchronously is not executed. Only the original html file is returned because the returned text is not parsed by the browser.
View code
A1.html
Copy codeThe Code is as follows:
<Html xmlns = "http://www.w3.org/1999/xhtml">
<Head>
<Title> No title page </title>
</Head>
<Script type = "text/javascript">
Function testClick ()
{
Document. getElementById ("tsrc"). src = "a2.html"
}
</Script>
<Body>
<Div style = "display: none"> <iframe id = "tsrc"> </iframe> </div>
<Input id = "Button1" type = "button" value = "asynchronously load script" onclick = "testClick ()"/>
</Body>
</Html>
A2.html
Copy codeThe Code is as follows:
<Html xmlns = "http://www.w3.org/1999/xhtml">
<Head>
<Title> No title page </title>
</Head>
<Body>
<Script>
Alert ('I am an asynchronous script ');
</Script>
</Body>
</Html>