Found this code it's in JQuery. When document is ready then that means the page is fully loaded.
// WHEN THE DOM HAS LOADED FIRE THE reCapInsert FUNCTION TO INSERT THE reCAPTCHA
$( document ).ready(function(){
reCapInsert();
});
// WHEN CALLED THIS INSERTS THE reCAPTCHA INTO THE PAGE
function reCapInsert(){
Recaptcha.create('YOUR_PUBLIC_KEY_HERE', // public key
'recap',
{
theme: 'clean',
callback: Recaptcha.focus_response_field
}
);
}
All you really do in your HTML page place this code and it will generate a ReCaptcha in that location. (Don't forget to include the recaptcha javascript in the headers of the page.)
<!-- The reCAPTCHA wrapper is here - this is required!! -->
<div id="recap"></div>
Found this example of Non-Ajax version getting loaded by $(document).ready()
$(document).ready(function(){
var json = {
type: "text/javascript",
scriptSrc: "http://www.google.com/recaptcha/api/challenge?k=6LcXq-oSAAAAAOgwSIew_xq6xkv1QUxrZbRcMz6n",
id: "theFrame",
iframeSrc: 'http://www.google.com/recaptcha/api/noscript?k=6LcXq-oSAAAAAOgwSIew_xq6xkv1QUxrZbRcMz6n'
};
var script = document.createElement('script');
script.type = json.type;
script.src = json.scriptSrc;
$('<iframe>', {
src: json.iframeSrc,
id: json.id,
frameborder: 0,
height: 300,
width: 500
}).appendTo('#recap');
});
JSFiddle: JSfiddle
For more information check out the original source: Mixing jQuery and reCaptcha