Category: Javascript

JavaScript for the masses.

Automatic iFrame Sizing

To add a second JavaScript code to allow embedding and auto-resizing of remote iframed pages, you can use the postMessage API to communicate between the iframe and the parent page. Below is an example of how you can achieve this. Automatic iFrame Sizing is easy! On the remote site (iframe content): <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8">

Using Javascript in PHP Code

Simpe method to use JavaScript inside PHP without all the messy code is a global function: function js_link($src) { //set root path to scripts folder if(file_exists("my/html/root/" . $src)) { //we know it will exists within the HTTP Context return sprintf("<script type="text/javascript" src="%s"></script>",$src); } return "<!-- Unable to load " . $src . "-->"; } Then use: echo