Posts

Showing posts from May, 2006

Javascript debugging Safari

Run this on the command line to enable Javascript debugging in Safari defaults write com.apple.Safari IncludeDebugMenu 1
Dynamically including javascript in a web page Aka: Ajax loading of javascript, runtime loading AJAX Response 1: req1.reponseText, req1.responseXML <script> alert("worked"); </script> AJAX Response 2: req2.responseText alert("worked"); Footnote is that the body tag could be swapped with the head tag. for scripts to work they have to be place in either the body or head tags //Example 1 doesn't work var body = document.getElementsByTagName("body"); var bodyElement = body.item(0); bodyElement.innerHTML = req1.responseText + bodyElement.innerHTML ; //Example 2 doesn't work var body = document.getElementsByTagName("body"); var bodyElement = body.item(0); bodyElement.appendChild(document.importNode(req1.responseXML.documentElement,true)); //Example 3 works var body = document.getElementsByTagName("body"); var bodyElement = body.item(0); var script = document.createElement("script"); script.setAtt

Dynamically including javascript in a web page

Dynamically including javascript in a web page Aka: Ajax loading of javascript, runtime loading AJAX Response 1: req1.reponseText, req1.responseXML script alert("worked"); /script AJAX Response 2: req2.responseText alert("worked"); Footnote is that the body tag could be swapped with the head tag. for scripts to work they have to be place in either the body or head tags //Example 1 doesn't work var body = document.getElementsByTagName("body"); var bodyElement = body.item(0); bodyElement.innerHTML = req1.responseText + bodyElement.innerHTML ; //Example 2 doesn't work var body = document.getElementsByTagName("body"); var bodyElement = body.item(0); bodyElement.appendChild(document.importNode(req1.responseXML.documentElement,true)); //Example 3 works var body = document.getElementsByTagName("body"); var bodyElement = body.item(0); var script = document.createElement("script"); script.setAttribute("lan