Topic: execute javascript tags in response, try this :D

Hi ppl,

it would very great if you enable javascript tags in the responses. ive got an little function from prototype and mootools big_smile

[code=Javacript]
function parse_js(data){       
    var scripts = '';
    var text = data.replace(/<script[^>]*>([\s\S]*?)<\/script>/gi, function(){
        scripts += arguments[1] + '\n';
        return '';
    });
    var script = document.createElement('script');
    script.setAttribute('type', 'text/javascript');
    script.text = scripts;
    document.getElementsByTagName('head')[0].appendChild(script);
    document.getElementsByTagName('head')[0].head.removeChild(script);
}
[/code]

if tried it on the assign/append function in the js core: xajax.dom.append = function(element, property, data) {...... parse_js(data);

and i wrote in my PHP code:
[code=php]
    $objResponse->append('kalender', "innerHTML", '
        AAA<b>aaa</b>
        <script type="text/javascript">
            var testmy = 509;
            alert(1);
        </script>
    ');
[/code]

and it works! the testmy is in the watch from my firebug and the alert works too big_smile

Re: execute javascript tags in response, try this :D

Hm, I like it! It's the perfect solution for lazy coders, hehe big_smile