Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                
              
            
!

CSS

              
                
              
            
!

JS

              
                   testCors();

   function testCors() {
     doCors("https://storage.googleapis.com/xliberation-store/corstest/testkey")
       .then(function(response) {
         console.log(JSON.parse(response.responseText));
       })
       .catch(function(err) {
         console.log(err);
       });

   }

   /**
    *do a cors request
    *@param {string}  url the url
    *@param {string} method the method (default GET)
    *@param {*} payload the optional payload
    *@return {object} the response
    */
   function doCors(url, method, payload) {
     return new Promise(function(resolve, reject) {
       return corsRequest(resolve, reject, url, method, payload);
     });
   }
   /**
    *do a cors request
    *thanks to http://enable-cors.org/ for info on cors/html5
    *@param {function} callback the load callback
    *@param {function} errorCallback the error callback
    *@param {string}  url the url
    *@param {string} method the method (default GET)
    *@param {*} payload the optional payload
    *@return {object} the response
    */
   function corsRequest(callback, errorCallback, url, method, payload) {

     // get the appropriate xhr
     var xhr = getXhr();
     if (!xhr) throw 'cant do cors with this browser';

     // now we can go
     xhr.open(method || "GET", url, true);

     // set up callbacks
     xhr.onload = function(evt) {
       // meed to catch this since it doesnt actually catch http errors
       if (evt.target.status < 200 || evt.target.status >= 300) {
         errorCallback(evt.target.responseText);
       } else {
         callback(evt.target);
       }

     }
     xhr.onerror = function(response) {
       errorCallback("request error- check that " + url + "exists and has CORS enabled");
     }

     // execute
     return xhr.send(payload);

     /**
      * get the correct xhr object for the browser being used
      * @return {XDomainRequest|XMLHttpReQuest} the xhr
      */
     function getXhr() {

       // likely to be this, unless its IE
       var xhr = new XMLHttpRequest();
       return isDefined(xhr.withCredentials) ?
         xhr : (isDefined(XDomainRequest) ? new XDomainRequest() : undefined);
     }

     function isDefined(ob) {
       return typeof ob !== typeof undefined;
     }

   }
              
            
!
999px

Console