Circumventing Chrome Access-control-allow-origin on the local file system?

I think I’ve figured it out.

All I really needed to do was add a callback into my <script> tag. Final code:

I have an element named next… So, in the $("#next").click() function I have the following code. This only gets executed if they click “next”.

//remove old dynamically written script tag-    
       var old = document.getElementById('uploadScript');  
   if (old != null) {  
     old.parentNode.removeChild(old);  
     delete old;  
   } 

   var head = document.getElementsByTagName("head")[0];  
   script = document.createElement('script');  
   script.id = 'uploadScript';  
   script.type="text/javascript";  
   script.src="https://stackoverflow.com/questions/4742467/test/" + scope_dir + '/js/list.js';  
   script.onload = refresh_page;    
   head.appendChild(script);  


function refresh_page(){  
   //perform action with data loaded from the .js file.  
}  

This seems to work, and allows Chrome to dynamically load .js files on the local file system while circumventing the access-control-allow-origin policy I ran into while trying to use jQuery functions.

Leave a Comment