Posts

Showing posts with the label script

Simulate Script Injection Via Data URI

Well, not only downloads on the fly , the data uri works for almost everything ( only iOS 5 beta does not want to work with inline data uri AUDIO sources .... but this is another story ... ) ... so ... How To Simulate Script injection Let's say you want a test but you don't want to bother a server. However, you want to be sure the test is asynchronous and it simulates the server. var head = document.getElementsByTagName("head")[0], script = document.createElement("script") ; head.insertBefore(script, head.lastChild); script.src = "data:text/javascript;base64," + btoa( "alert('Hello World')" ); How To Simulate JSONP Same trick, isn't it? ... except: script.src = "data:text/javascript;base64," + btoa( "callback(" + JSON.stringify(dummyData) + ")" ); How To Drop Server Requests well, this is the tricky one ... Surely there is some job to do in the createResponse() function but ... he...

Script Type PHP :)

Update 2008/03/15 I have removed preg_replace and added DOM classes to parse and manage, in a better way, script nodes that contain php code. Everything inside a simple PHP 5 compatible class . Finally, please remember that this is a layer between <?php ?> and JavaScript, and only an experiment ;) Here you can read another example, where difference between server, output, and client, should be more clear than precedent one. <?php require ' PHPScriptHandler.php '; ?> <html> <head> <title>Hello PHP World</title> <script type="text/php" author="andr3a"> // here we are between the server and output, known as client $hello = ucwords('hello php world'); // imagine that we would like to use a variable // defined somewhere in the server global $something; // we could even include or require php ...