Safeguard - demo

A JavaScript library that tries to sandbox 3rd party content on a webpage.

The host page is using Bootstrap for CSS styles, which affect things like: and <code></code>

It also comes with its own typography and helpers, e.g.

h1. Bootstrap heading

h2. Bootstrap heading

h3. Bootstrap heading

h4. Bootstrap heading

h5. Bootstrap heading
h6. Bootstrap heading

You can use the mark tag to highlight text.

This line of text is meant to be treated as deleted text.

This line of text is meant to be treated as no longer accurate.

This line of text is meant to be treated as an addition to the document.

This line of text will render as underlined

This line of text is meant to be treated as fine print.

This line rendered as bold text.

This line rendered as italicized text.


Example of using Safeguard

The following box has content that's in this page, wrapped in a <safe-guard></safe-guard> element.

Text content, no styling. e.g.
<safe-guard>
  Text content, no styling.
</safe-guard>   
        

The same content from earlier, but now in a <safe-guard>. Notice that the content is from the host page & has styles applied, but now sandboxed in a safe-guard the browser default styles are used.

The host page is using Bootstrap for CSS styles, which affect things like: and <code></code>

It also comes with its own typography and helpers, e.g.

h1. Bootstrap heading

h2. Bootstrap heading

h3. Bootstrap heading

h4. Bootstrap heading

h5. Bootstrap heading
h6. Bootstrap heading

You can use the mark tag to highlight text.

This line of text is meant to be treated as deleted text.

This line of text is meant to be treated as no longer accurate.

This line of text is meant to be treated as an addition to the document.

This line of text will render as underlined

This line of text is meant to be treated as fine print.

This line rendered as bold text.

This line rendered as italicized text.

This <safe-guard></safe-guard> element is tagged with 'myWidget", meaning any resource alos tagged 'myWidget' will be dragged into the safeguard fragment. In this case, a custom stylesheet with a CSS class hopefully making this div have an orange background.

Another custom style in the same stylesheet. This paragraph should have green background, white text...

Code:

<html>
  <head>
    <style data-safeguard-tag="myWidget">
    .custom1 {
      font-family: monospace;
      font-size: 22px;
      font-weight: bold;
      background: green;
      color: white;
    }
    .custom2 {
      font-family: 'Times New Roman', Times, serif;
      font-size: 24px;
      background: orange;
    }
    </style>
  </head>

  <body>
    <safe-guard tag="myWidget">
      <div class="custom2">
        <p>This <safe-guard></safe-guard> element is tagged with 'myWidget", meaning any
          resource alos tagged 'myWidget' will be dragged into the safeguard fragment. In this case, a custom
          stylesheet with a CSS class hopefully making this div have an orange background.
        </p>
        <p class="custom1">
          Another custom style in the same stylesheet. This paragraph should have green background, white text...
        </p>
      </div>
    </safe-guard>
  </body>
</html>

        
Force the custom element to use the iframe strategy

I should have custom styles...

<safe-guard iframe>
  Force the custom element to use the iframe strategy
  ...
</safe-guard>   
        

Using data-safeguard attribute on any element is also supported

This content started in the parent document.
This content started in the parent document.

I should have custom styles...

This content started in the parent document.
<div data-safeguard>
  Force the custom element to use the iframe strategy
  ...
</div>   
This content started in the parent document.
This content started in the parent document.

I should have custom styles...

This content started in the parent document.
This content started in the parent document.

Static document content…

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus porttitor neque quam, sed placerat ipsum rutrum at. Integer consequat consequat quam, vel elementum nisl convallis cursus. Mauris iaculis neque urna. Nulla congue laoreet mattis. Etiam molestie, libero ut aliquet tincidunt, turpis enim pretium arcu, tempor mattis nunc justo nec eros. Sed massa elit, vulputate sed massa ut, egestas pulvinar lectus. Sed pretium est id tempor luctus. Curabitur id iaculis dui. In tempor sodales semper. Aliquam sollicitudin eleifend bibendum. Suspendisse viverra augue vitae enim viverra, in pellentesque justo imperdiet. Mauris luctus suscipit erat porttitor tempor.

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus porttitor neque quam, sed placerat ipsum rutrum at. Integer consequat consequat quam, vel elementum nisl convallis cursus. Mauris iaculis neque urna. Nulla congue laoreet mattis. Etiam molestie, libero ut aliquet tincidunt, turpis enim pretium arcu, tempor mattis nunc justo nec eros. Sed massa elit, vulputate sed massa ut, egestas pulvinar lectus. Sed pretium est id tempor luctus. Curabitur id iaculis dui. In tempor sodales semper. Aliquam sollicitudin eleifend bibendum. Suspendisse viverra augue vitae enim viverra, in pellentesque justo imperdiet. Mauris luctus suscipit erat porttitor tempor.

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus porttitor neque quam, sed placerat ipsum rutrum at. Integer consequat consequat quam, vel elementum nisl convallis cursus. Mauris iaculis neque urna. Nulla congue laoreet mattis. Etiam molestie, libero ut aliquet tincidunt, turpis enim pretium arcu, tempor mattis nunc justo nec eros. Sed massa elit, vulputate sed massa ut, egestas pulvinar lectus. Sed pretium est id tempor luctus. Curabitur id iaculis dui. In tempor sodales semper. Aliquam sollicitudin eleifend bibendum. Suspendisse viverra augue vitae enim viverra, in pellentesque justo imperdiet. Mauris luctus suscipit erat porttitor tempor.

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus porttitor neque quam, sed placerat ipsum rutrum at. Integer consequat consequat quam, vel elementum nisl convallis cursus. Mauris iaculis neque urna. Nulla congue laoreet mattis. Etiam molestie, libero ut aliquet tincidunt, turpis enim pretium arcu, tempor mattis nunc justo nec eros. Sed massa elit, vulputate sed massa ut, egestas pulvinar lectus. Sed pretium est id tempor luctus. Curabitur id iaculis dui. In tempor sodales semper. Aliquam sollicitudin eleifend bibendum. Suspendisse viverra augue vitae enim viverra, in pellentesque justo imperdiet. Mauris luctus suscipit erat porttitor tempor.