- Building Web and Mobile ArcGIS Server Applications with JavaScript(Second Edition)
- Eric Pimpler Mark Lewin
- 260字
- 2021-07-02 15:48:58
Making sure the DOM is available
When a web page loads, all the HTML elements that comprise the page are loaded and interpreted. This is known as the DOM (Document Object Model). Your JavaScript must not attempt to access any of these elements until all the elements have loaded. Obviously if your JavaScript code attempts to access an element that hasn't been loaded it will cause an error. To control this, Dojo has a ready() function that you can include inside the require() function, which will execute only after all the HTML elements and any modules have loaded. Alternatively, you can use the dojo/domReady! plugin to ensure that all the HTML elements have been loaded. We'll use the second method here:
<script> require(["esri/map", "dojo/domReady!"], function(Map) { }); </script>
Note that, even though we have included the dojo/domReady! module in the list of modules we want to load, we have not provided an alias for it. This is because although we need the plugin to inform the application that the DOM is ready, we don't need to refer to it explicitly in our code. This is the exception to the rule we mentioned earlier.
- Vue 3移動(dòng)Web開(kāi)發(fā)與性能調(diào)優(yōu)實(shí)戰(zhàn)
- Microsoft Exchange Server PowerShell Cookbook(Third Edition)
- JavaScript高效圖形編程
- Access 2016數(shù)據(jù)庫(kù)管
- Ext JS 4 Web Application Development Cookbook
- Learning SciPy for Numerical and Scientific Computing(Second Edition)
- 編程可以很簡(jiǎn)單
- ASP.NET求職寶典
- 3D Printing Designs:The Sun Puzzle
- 現(xiàn)代C++語(yǔ)言核心特性解析
- 輕松學(xué)Scratch 3.0 少兒編程(全彩)
- Java核心技術(shù)速學(xué)版(第3版)
- Cinder:Begin Creative Coding
- Visual C++程序開(kāi)發(fā)范例寶典
- Learning RSLogix 5000 Programming