I have a web form that uses reCAPTCHA to filter robots. The form has a tag <script>that loads captcha's call <iframe>. If this script does not load, then the captcha call will not appear and no one will be able to send the message.
<script>
<iframe>
Is there any way I can determine if the script is loaded so that I can disable this function on my part?
Attach an event loadto an element scriptthat points to reCAPTCHA.
load
script
var script = document.createElement("script"); script.addEventListener("load", function() { // Script has loaded. }); script.src = "/path/to/recaptcha.js"; document.body.appendChild(script);
, , , captcha. / script. .
A script , , captcha.
script.addEventListener will not work with IE8 and IE7. for this you need
if (!script.addEventListener) { script.attachEvent("onload", function(){ // script has loaded in IE 7 and 8 as well. }); } else { script.addEventListener("load", function() { // Script has loaded. }); }