1. Create a EXTJS window, request HTML files with Ajax, and execute HTML code and scripts
The text in the form is taken from one HTML, and the script is executed in HTML to highlight the form for 1 seconds
Main Page:
<!DOCTYPE HTML><HTML> <Head> <Linkrel= "stylesheet"type= "Text/css"href=".. /.. /extjslib/resources/css/ext-all.css " >ExtJS Style<Scripttype= "Text/javascript"src=".. /.. /extjslib/adapter/ext/ext-base-debug.js "></Script>ExtJS Base Library<Scripttype= "Text/javascript"src=".. /.. /extjslib/ext-all-debug-w-comments.js "></Script>ExtJS Component Library<Scripttype= "Text/javascript">Ext.blank_image_url= ".. /.. /extjslib/resources/images/default/s.gif"; //placeholder pictures, which should be specified before the app code executes </Script> <Scripttype= "Text/javascript"src= "Autoload.js"></Script> </Head></HTML>
This note JS loading sequence, if the foundation to first load, do not write the reverse, resulting in JS error, for a glimpse of the person, each JS library has the corresponding debug footsteps
Autoload.js
functionBuildwindow () {varWin =NewExt.window ({//Create a Window instanceID: ' Mywindow ',//instance ID, which can be queried by the ext.getcmp methodTitle: ' Window Demo AutoLoad ', Width:300, Height:150, layout:' Fit ',//layout to fill a window with the contents of the formautoload:{//Auto LoadURL: ' sayhi.html ',//loads the page URL, where only HTML fragments are displayedScriptstrue//Execute Load page script, but execute block and row level scripts } }); Win.show ();//Display window}ext.onready (Buildwindow);//the Onready method is performed before the picture is loaded after the DOM is ready
Sayhi.html
<div>hello from the <b> world</b> of Ajax</div><script type= "Text/javascript" > function Highlightwindow () { var win = ext.getcmp (' Mywindow '); Get window instance var winbody = win.body; winbody.highlight (); } Highlightwindow.defer (1000); // execute </script> after 1 seconds
The highlight here is defer, which is more convenient than settimeout because
1. Simpler, any function can do this, just pass a time
2. You can control the methods that are deferred and the scope of execution, and pass in the set parameters (the exact words, not quite understood)
ExtJS Example 1