cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

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.

Quick-add: + add another resource

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.

Quick-add: + add another resource

Code Indentation

     

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.

            
              <button onclick="showNewtorkInformation();">Show Network Information</button>

<p class="message information"></p>

<p class="message error noAPI">
  You browser does not support <span>navigator.connection</span>
</p>

<p class="message error incompleteAPI">
  You browser has incomplete implementation of <span>navigator.connection</span>. Things like <span>navigator.connection.type</span> and <span>navigator.connection.downlinkMax</span> are used in this demo.
</p>
            
          
!
            
              .message {
  padding: 20px;
  line-height: 2;
  border: 1px solid #f2f2f2;
  display: none;
  
  &.error {
    border: 1px solid #e60000;
    background: #ffb3b3;
    color: #e60000;
  }
  
  a {
    text-decoration: none;
    color: white;
    font-weight: bold;
  }
  
  span {
    border: 1px solid white;
    border-radius: 5px;
    padding: 5px;
    background: #f2f2f2;
  }
}

.show {
  display: block;
}

button {
  display: block;
  width: 50%;
  height: 50px;
  margin: 20px auto;
  background:  #99ff99;
  border: 1px solid #00e600;
  color: #008000;
  cursor: pointer;
}
            
          
!
            
              function showNewtorkInformation() {
  if(!navigator.connection) {
    showMessage('.noAPI');
    return;
  }

  if(!navigator.connection.type || !navigator.connection.downlinkMax) {
    showMessage('.incompleteAPI');
    return;
  }
  
  let text = `
    Connection type as obtained from
    <span>navigator.connection.type</span>
    : ${navigator.connection.type}.
    <br/>
    Connection downlink as obtained from
    <span>navigator.connection.downlinkMax</span>
    : ${navigator.connection.downlinkMax}.
    <br/>
    Connection effective type as obtained from
    <span>navigator.connection.effectiveType</span>
    : ${navigator.connection.effectiveType}.
    <br/>
    Connection RTT as obtained from
    <span>navigator.connection.rtt</span>
    : ${navigator.connection.rtt}.
  `;
   
    document.querySelector('.information')
      .innerHTML = text;
    showMessage('.information');
  
    // Handle Change in type or downlink information
    navigator.connection
      .addEventListener('change', showNewtorkInformation);
}

function showMessage(classname) {
  document.querySelector(classname).classList.add('show');
}
            
          
!
999px
Loading ..................

Console