Ex! Developer Network

'javascript' 的相关日志共 1 篇

  1. 2008/05/07 让 innerHTML 中的脚本跑起来 (1)
我们知道普通方式 innerHTML 到容器中的脚本浏览器器是不会执行的,今天看 mootools 的时候发现靠它可以做到.

Ajax 类的说明:
Class: Ajax
    An Ajax class, For all your asynchronous needs.
    Inherits methods, properties, options and events from <xhr>.

Arguments:
    url - the url pointing to the server-side script.
    options - optional, an object containing options.

Options:
    data - you can write parameters here. Can be a querystring, an object or a Form element.
    update - $(element) to insert the response text of the XHR into, upon completion of the request.
    evalScripts - boolean; default is false. Execute scripts in the response text onComplete. When the response is javascript the whole response is evaluated.
    evalResponse - boolean; default is false. Force global evalulation of the whole response, no matter what content-type it is.
   
Events:
    onComplete - function to execute when the ajax request completes.</xhr>



Example:
>var myAjax = new Ajax('js.txt', {method: 'get', update: $$('body'), evalScripts: true}).request();
js.txt:
<script type="text/javascript"> alert('TEST'); </script>
代码片段 l 2008/05/07 15:11
1 

日志分类

所有分类 (10)
作品展示 (7)
代码片段 (3)

日历

«   2008/07   »
    1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31    
tistory!get rsslazylogs Tistory Tistory 가입하기!