Strange problems encountered when using document. write on a webpage

Source: Internet
Author: User

During the previous research on porting the Razor template engine to JavaScript, I found that if you use document. the write output contains the <script> flag that calls external JavaScript, which may cause a problem. The called external JavaScript may be executed at an inappropriate time, for IE and Opera, the external JavaScript will be executed only after all the other parts of the write parameter are parsed.

In further research, I found that for Chrome and Safari browsers that use the WebKit web page typographical engine, if the externally called JavaScript calls document again. write to write the <script> flag of another external JavaScript call, the external JavaScript called for the second time will not be executed, some subsequent content will also be disrupted-the actual situation is actually a little more complicated, with level 2 and level 3 document. the specific content of the write call parameter is related, because the time and energy are related, I cannot perform more specific tests.

After these studies, the only major browsers that survive and can correctly handle all document. write calls will be Firefox.
The processing feature of a pseudo "multi-thread" event in Firefox has always been something that I don't want to wait for. It is also an evidence of "each has its own strengths.

.

Over the past few days, I have been trying to write a replacement function to solve this problem. Now I can successfully pass the test in the link above.
If no obvious problem is found in the next few days, I will post it on my blog for your reference.
Test code, package and download

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.