Web hosting services - CHAPTER 3 CONTENT CHUNKING PATTERN var asynchronous

CHAPTER 3 CONTENT CHUNKING PATTERN var asynchronous = new Asynchronous(); asynchronous.complete = function(status, statusText, responseText, responseXML) { eval(responseText);

Nothing

When the user clicks the Get Script button, an XMLHttpRequest request is made that retrieves the document /chap03/chunkjs01.html. The document contains a JavaScript chunk that is executed by using the eval function. The following chunk is downloaded: window.alert(”oooowweee, called dynamically”); The example chunk is not very sophisticated and pops up a dialog box. What would concern many people with arbitrarily executing JavaScript code is that arbitrary JavaScript code is being E B V N executed. An administrator and user might be concerned with the security ramifications because viruses or Trojans could be created. However, that is not possible because JavaScript executes within a sandbox and the same origin policy applies. Granted, if a developer bypasses the same origin policy, security issues could arise. When receiving JavaScript to be executed, a simple and straightforward implementation is to dynamically create a JavaScript chunk that executes some methods. The JavaScript chunks make it appear thatthewebbrowser is doing something.For example,the JavaScript chunk downloaded in the previous example could be used to assign the spanor td tag as illustrated here: document.getElementById(”mycell”).innerHTML = “hello”; The generated script is hard-coded in that it expects certain elements to be available in the destination HTML page. Generating a JavaScript That Manipulates the DOM Earlier you saw the image generation solution in which an image was broken and then made complete by downloading a valid link. It is also possible to download an image by modifying the Dynamic HTML object model. You modify the object model by using a JavaScript chunk to insert the img tag. The following is an example image JavaScript chunk that creates a new img tag and chunks it into the HTML document: var img = new Image() img.src = “/static/patches01.jpg” document.getElementById(”insertplace”).appendChild(img)
Please visit Domain Name Hosting services for high quality webhost to host and run your jsp applications.

Leave a Reply