Once I assign this code to load the function on window.onload event: window.onload = initfunction;
I am looking to add an AJAX cross domain script to the header:
function initfunction() { var dh = document.getElementsByTagName('head')[0]; var script = null; script = document.createElement('script'); script.setAttribute('src', 'http://whatever.com/cgi-bin/ACD/ACD.js?' + location.href); script.setAttribute('type', 'text/javascript'); dh.appendChild(script); }
The script appears to be added with the correct domain name, but Firebug keeps showing "Failed to load source" error. It works when a fixed URL is entered in the src attribute! For example:
script.setAttribute('src', 'http://whatever.com/cgi-bin/ACD/ACD.js?http://google.com');
Any suggestions or insights?