项目作者: codeprofis

项目描述 :
DGSVO-compliant integration of a Google Maps IFrame with prior confirmation.
高级语言: JavaScript
项目地址: git://github.com/codeprofis/cpIFramePrivacy.git
创建时间: 2019-03-07T10:58:36Z
项目社区:https://github.com/codeprofis/cpIFramePrivacy

开源协议:MIT License

下载


cpIFramePrivacy

DGSVO-compliant integration of IFrames (Google Maps for example) with prior confirmation.

How to integrate

It is easy to integrate cpIFramePrivacy.

The integration is finally done in 4 steps:

  1. Integrate cpIFramePrivacy.min.js as <script> in the Header-Section of your page.

  2. A div container - identified by a unique ID (in the examples we use mapContainer as the ID) - is created at the previous location of the iframe. The styles of the previous frame are assigned to this container. The attribute data-url is used to specify the iframes URL. The attribute data-confirmation-message specifies the ID of the container created in the next step.

  3. Next, a div container containing the confirmation message has to be defined (we define it as a direct sibling of mapContainer in our examples). This div can be designed freely.
    The HTML element, which is actually clicked by the user for confirmation, must contain the class cpIframePrivacy__confirm-button.

  4. At the end of the body area the iframes are initialized using the following script:

    1. <script>
    2. cpIFramePrivacy.initIFrame('mapContainer');
    3. </script>

Simply have a look at the example in example/Example.html

You can easily use it for multiple iframe instances within the same page.

cpIFramePrivacy can store user’s confirmation in a cookie, which leads to not showing the confirmation message again for a specified time (1 day by default)

  1. <script>
  2. cpIFramePrivacy.setCookieEnabled(true);
  3. cpIFramePrivacy.initIFrame('mapContainer');
  4. </script>

You can easily adjust the expiry time of the cookie by invoking cpIFramePrivacy.setCookieDuration with number of days as an argument:

  1. <script>
  2. cpIFramePrivacy.setCookieEnabled(true);
  3. cpIFramePrivacy.setCookieDuration(2); // <--- sets the cookie expiry time to two days
  4. cpIFramePrivacy.initIFrame('mapContainer');
  5. </script>