Let’s look at the example first:
]
This paragraph, After ifr.src is placed in append, it runs. There is nothing on the surface and it seems normal. But if you use the packet capture tool to take a look, you will find that when refreshing (F5 or refresh button), there will be 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? This problem is gone!
Similar ones are:
Put ifr.frameBorder = 0 after append, this iframe can still see the border. Before putting it in append, the border is 0.
If you put ifr.scrolling = "no" after append, it will not work. If you put it before append, it will work.
Ifr.width and ifr.height have no effect whether they are placed in front or behind.
However, if you want to add a temporary parameter after the iframe address to achieve the effect of requesting a new page every time, putting ifr.src before append will not work (refresh or F5)!
Such as code:
If you need to introduce external Js, you need to refresh to execute
]You can monitor it, every time you refresh , that tmp is all the same value! Unless you reload (not F5/Refresh). What about another method? Use document.write to achieve? I can tell you, it doesn’t work either!