First look at the example:
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd "> <ptml xmlns=" http://www.w3.org/1999/xhtml "> <pead> <meta http-equiv=" Content-type "Content=" Tex t/html; Charset=utf-8 "/> <title> Untitled document </title> </pead> <body> <script language=" JavaScript " Type= "Text/javascript" > var IFR = document.createelement ("IFRAME"); Document.body.appendChild (IFR); IFR.SRC = "http://www.baidu.com"; </script> </body> </ptml>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]
This paragraph, ifr.src put after append, run, the surface is nothing, seemingly normal. But if you look at it with a grab tool, you'll find that when you refresh (F5 or refresh the button), you get one more request:
00:00:04.671 0.021 * Get aborted text/html http://www.baidu.com/
Although the status is aborted, this request is still sent to the server!
What if you put ifr.src before append? The problem is gone!
There are also similar:
After putting Ifr.frameborder = 0 on the append, the IFRAME can still look at the border. Before you put it in the append, the border is 0.
The ifr.scrolling = "No" After the append, does not work, put to append before it works.
The ifr.width,ifr.height has no effect on the front or the rear.
However, if you want to add a temporary parameter to the address of the IFRAME to achieve the effect of requesting a new page each time, put the ifr.src in the append before you go (refresh or F5)!
such as code:
<textarea id="runcode23705"><! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd "> <ptml xmlns=" http://www.w3.org/1999/xhtml "> <pead> <meta http-equiv=" Content-type "Content=" Tex t/html; Charset=utf-8 "/> <title> Untitled document </title> </pead> <body> <script language=" JavaScript " Type= "Text/javascript" > var IFR = document.createelement ("IFRAME"); Ifr.frameborder = 0; ifr.scrolling = "No"; IFR.SRC = "http://www.baidu.com?tmp=" + (new Date (). GetTime (). ToString (36)); Document.body.appendChild (IFR); Ifr.width = 500; Ifr.height = 500; </script> </body> </ptml></textarea>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]
You can monitor, every time you refresh, that TMP is the same value! Unless you reload (not f5/refresh).
A different way? Use document.write to achieve? Can tell you, also not!