/* * Copyright (c) 2011 The Pickling Jar Ltd <*****@*****.**> * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ require 'webkitdlib.php'; $globalerrcode = null; $globalerrstr = null; //connect to webkitd $fd = webkitd_connect('127.0.0.1', 3817); if ($fd == false) { die('Error: webkitd couldn\'t connect' . "\n"); } //runjs returns the result of the last function called - so wrap in anon function $res = webkitd_runjs($fd, "(function(){ var i = 10; return i })();"); echo $res; $res = webkitd_close($fd); if ($res == false) { die('Error: webkitd couldn\'t close' . "\n"); }
echo "Iframe Count: ".$res; for($i = 0; $i<$res; $i++){ echo "IFrame $i: ".webkitd_iframesourceurl($fd,$i)."\n"; } */ echo "IFRAME HTML: " . webkitd_gethtml($fd) . "\n"; $res = webkitd_runjs($fd, "document.getElementById('ppp').innerHTML = 'basic js'"); echo "IFRAME HTML: " . webkitd_gethtml($fd) . "\n"; $res = webkitd_runjs($fd, "(function(){ _jQuery('#ppp').html('jquery text')})();"); echo "IFRAME HTML: " . webkitd_gethtml($fd) . "\n"; webkitd_iframeselect($fd, 0); //mainframe webkitd_iframeselect($fd, 0 + 1); //first iframe echo "IFRAME HTML: " . webkitd_gethtml($fd) . "\n"; $res = webkitd_runjs($fd, "(function(){ _jQuery('#ppp').html('jquery text 2')})();"); echo "IFRAME HTML: " . webkitd_gethtml($fd) . "\n"; } /* //back to mainframe //webkitd_iframeselect($fd, 0); */ //webkitd_runjs($fd, "_jQuery('#content').html('jquery text 2');"); //echo "html: ".webkitd_gethtml($fd); //webkitd_showbrowser($fd, 10); /* //return url as it might not be the one we set due to 301s/302s etc $url = webkitd_returnurl($fd); if($url == false){ webkitd_close($fd); die('Error: webkitd couldn\'t return url'."\n");