Ovaj JS snippet sam negde pokupio, ne znam tacno gde:
Citat:
Executing Javascript
Since the browser won't execute <script> tags when changing innerHTML, you may want to apply the following function call on document.getElementById(target):
PHP kôd:
var bSaf = (navigator.userAgent.indexOf('Safari') != -1); var bOpera = (navigator.userAgent.indexOf('Opera') != -1); var bMoz = (navigator.appName == 'Netscape'); function execJS(node) { var st = node.getElementsByTagName('SCRIPT'); var strExec; for(var i=0;i<st.length; i++) { if (bSaf) { strExec = st[i].innerHTML; } else if (bOpera) { strExec = st[i].text; } else if (bMoz) { strExec = st[i].textContent; } else { strExec = st[i].text; } try { eval(strExec.split("<!--").join("").split("-->").join("")); } catch(e) { alert(e); } } }
JavaScript Notes:
* IE always returns tags in UPPER CASE, so you must search for SCRIPT and not script. Keep your SCRIPT tags in upper case for Firefox compatibility.
* Do not use // comments, use /* */ instead. The eval executes all your javascript as though it was on one line, so you must end each statement with a semicolon (.
* Any functions declared in your JavaScript will go out of scope once the eval statement completes. It is possible to keep them in scope by attaching them as a method to a function that was defined at the document level.
|
EDIT: A evo sad nadjoh nesto jos bolje: http://24ways.org/advent/have-your-d...-script-it-too
__________________
Leadership is the art of getting people to want to do what you know must be done.
Poslednja izmena od ivanhoe : 27. 11. 2006. u 23:16.
|