目的:动态加载javascript
两种方式:
1.
function include(src) {
HTMLCode = '<script language="javascript" src="' + src + '"></script>';
var tags = document.getElementsByTagName("head");
var html = tags[0].innerHTML;
tags[0].innerHTML = HTMLCode + html;
}
2.
function include(src) {
var s = document.createElement('script');
s.src = src;
var tags = document.getElementsByTagName("head");
tags[0].appendChild(s);
}
假设动态加载的src中含有全局变量 var all=123;
测试的时候第一种方式是拿不到这个全局变量的,而第二种是可以的,但两种方式下inspect可以看到文档中均已经加载src,想请教缘由?
分享到:
相关推荐
Infused with entrepreneurial spirit and the excitement of a worthy challenge, this book is the opposite of pessimistic recitals of intractable poverty's horrors. -----------------------------------...
37. What is the difference between the SAP HANA enterprise edition and the SAP HANA platform edition? 38. Are there any special SAP HANA options that can be purchased on top of the standard SAP HANA ...
This document contains the solutions to review questions and problems for the 5th edition of Computer Networking: A Top-Down Approach by Jim Kurose and Keith Ross. These solutions are being made ...
• Investment analysts who want to know what might go wrong with their investments, why, and how to stop it. • Project office staff who want to know how to integrate the information they get from the...
And you will be challenged to think about what’s right about that code, and what’s wrong with it. More importantly, you will be challenged to reassess your professional values and your commitment ...
I have chosen the 10000 number as a good case in both read and writes, you are welcome to tinker with this on your own systems and see what works better for you. Performance Tests v2.3 In v2.3 a ...
A brief note about what I cover: the access lists in this book deal only with the Internet Protocol (IP), though you could probably use many of the same techniques with other network protocols as ...
As every C++ programmer knows, the language has many powerful features, but this power brings with it complexity, which in turn can make code more bug-prone and harder to read and maintain....
The more austere of these maintain a conscientious difference of opinion concerning, among other things, subjects fit for art, and reveal an inability to associate the idea of the sub-title adjective ...
1. Making Games the Modular Way 1 1.1 Important Programming Concepts.....................................2 1.1.1 Manager and Controller Scripts...............................2 1.1.2 Script ...
6 , chunks.zip This will open a file and read it in "Chunks" of a selected file.<END><br>7 , logging.zip This is a bas that will log installation procedures so the file can be removed later....
3. Size Stats: Shows the build's file size, and a table breaking down of which assets are taking up what percentage of space on the build. 4. Used Assets: Shows a list of *all* assets that were ...
Is there any difference between the books? - W: There are pictures in the expensive one. - **知识点:** - **词汇:**expensive(昂贵的)、cheaper(更便宜的)、picture(图片) - **语法:**使用比较级...
3) SRS with writeback must have a separating space after the mode number and before "!" (eg. "SRSDB 16 !" instead of "SRSDB 16!") 4) macro, rept, irp, format, if, virtual etc. are all significant ...
6. “What's the weather like today?” 是询问天气状况的常用句式。 7. “Where are you headed?” 用于询问对方的目的地或计划去的方向。 8. “I wasn't born yesterday.” 表示自己并不天真,对某些事情有所...
5. **What's the weather like today?**(今天天气怎么样?):了解当天天气状况的基本句型。 6. **Where are you headed?**(你要去哪儿?):询问目的地或下一步计划时使用。 7. **I wasn't born yesterday.**(我...
- **例句**: "This place isn’t perfect but it’s good enough." "Don’t be so fussy!" #### 16. Don’t count on me! 别指望我! - **应用场景**: 表示不愿意或不能参与某事。 - **例句**: "We’re going to ...
5. **What's the weather like today?**(今天天气怎么样?):询问天气状况,常用于寒暄。 6. **Where are you headed?**(你要去哪里?):询问对方的目的地或计划。 7. **I wasn't born yesterday.**(我不是...