css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

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.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

              <div class="wrapper">
<h1>Come sfruttare le Notification API</h1>

<p>In questa pagina &egrave; presente del codice che permette di sfruttare le <em>Page Visibility API</em> per attivare le <em>Notification API</em> che ci consentono di <strong>inviare notifiche push.</strong></p>
<p>Se non sai bene di cosa sto parlando, puoi trovare tutte le informazioni che desideri nell'articolo pubblicato su SkillsAndMore</a>.</p>

<div class="cta-sam"><a href="https://skillsandmore.org/notifiche-push-sito/" target="_blank">Scopri l'articolo completo</a></div>

  background-color: #f5f5f5;
  font-family: "Open Sans";
  text-align: center;
  max-width: 900px;
  margin: 100px auto 50px;
  font-family: "Bree Serif";
  font-size: 40px;
  margin: 30px auto;
  text-align: center;

.cta-sam a{
  background-color: #EF6C00;
  display: inline-block;
  padding: 20px;
  margin: 10px auto;
  border-radius: 6px;
  color: #fff;
  text-decoration: none;

.cta-sam a:hover{
  background-color: #333;
              // Based on the tutorial at https://developer.mozilla.org/en-US/docs/Web/Guide/User_experience/Using_the_Page_Visibility_API
(function() {
  'use strict';

  // Veriabili di controllo
  var hidden, visibilityChange; 
  // Controllo tipo di evento
  if (typeof document.hidden !== "undefined") { //Per tutti i browser moderni
    hidden = "hidden";
    visibilityChange = "visibilitychange";
  } else if (typeof document.mozHidden !== "undefined") { // Firefox fino v17
    hidden = "mozHidden";
    visibilityChange = "mozvisibilitychange";
  } else if (typeof document.webkitHidden !== "undefined") { // Chrome fino v32, Android fino v4.4, Blackberry fino v10
    hidden = "webkitHidden";
    visibilityChange = "webkitvisibilitychange";

  if (typeof document.addEventListener === "undefined" || typeof document.hidden === "undefined") {
    // Lascio un messaggio se il browser non supporta le Page Visibility API
    alert("Hai bisogno di un browser moderno per utilizzare le Page Visibility API.");
  } else {
    // Se tutto va bene mi metto in ascolto dell'evento visibilityChange
    document.addEventListener(visibilityChange, handleVisibilityChange, false);

  function notify(message) {
      // Controlliamo se il browser supporta le notifiche
      if (!("Notification" in window)) {
          alert("Questo browser non supporta le Notification API, usa un browser moderno");

      // Controlliamo se l'utente accetta le nostre notifiche
      else if (Notification.permission === "granted") {
          // Se è tutto a posto, creiamo una notifica
          var notification = new Notification(message);

      // Se l'utente non ha accettato le notifiche, chiediamo il permesso
      else if (Notification.permission !== 'denied') {
          Notification.requestPermission(function (permission) {
            // Se è tutto a posto, creiamo una notifica
            if (permission === "granted") {
                var notification = new Notification(message);

  function handleVisibilityChange() {
    if (document.hidden) {
      // Messaggio se la pagina è nascosta
      notify('Sei andato via! :\('); 
    } else {
      // Messaggio se la pagina è visibile
      notify('Grande! Sei tornato :\)'); 

🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................