Dynamically generated IFRAME, the impact of different locations when SRC is set

Source: Internet
Author: User

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 =" text/html; charset = UTF-8 "/> <title> www.www.jb51.net </title> </pead> <body> </ptml>
[Ctrl + A select all Note: If you need to introduce external Js, You need to refresh it to execute]

In this section, ifr. src is put after append and runs. The surface is nothing, and it seems to be normal. However, if you use the packet capture tool, you will find that when you refresh (F5 or refresh button), there will be an additional 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 I put ifr. src before append? This problem is gone!

Similar:
Put ifr. frameBorder = 0 after append, the iframe can still be viewed as the border. Put it before append, and the border is 0.
Put ifr. scrolling = "no" after append, it does not work. put it before append.
Ifr. width and ifr. height are not affected either before or after placement.


However, if you want to add a temporary parameter to the iframe address to request a new page every time. src cannot be placed before append (when refreshing or F5 )!

Such as code:

<! 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 =" text/html; charset = UTF-8 "/> <title> www.www.jb51.net </title> </pead> <body> </ptml>
[Ctrl + A select all Note: If you need to introduce external Js, You need to refresh to execute] You can monitor that every time you refresh, The tmp is the same value! Unless you reload (not F5/refresh ).
What about the alternative method? Use document. write to implement? I can tell you, either!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.