Jump to content
Search Community

AlexeyBoldin

Members
  • Posts

    15
  • Joined

  • Last visited

Community Answers

  1. AlexeyBoldin's post in responsive html5 banner with video was marked as the answer   
    After a few corrections Yandex accepted this code:
     


    <!DOCTYPE html>
    <html>
    <head>
    <script type="text/javascript" src="https://awaps.yandex.net/data/lib/adsdk.js"></script>
    <meta charset="utf-8" name="ad.size" content="width=320,height=268">
    <title>320x268_YandexVideo</title>
    <!-- write your code here -->
    <script>
    function getUrlParam(name) {
    name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
    var regex = new RegExp("[\\?&]" + name + "=([^]*)"),
    results = regex.exec(location.search);
    return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
    }
    </script>
    <style>
    body {
    margin: 0px;
    height: 100%;
    overflow: hidden;
    cursor: pointer;
    }

    #video {
    border: 1px solid gray;
    width: 100% !important;
    height: 100% !important;
    min-width: 320px;
    max-width: 1080px;
    min-height: 268px;
    max-height: 328px;
    object-fit: contain;
    position: fixed;
    margin: auto;
    left: 0;
    right: 0;
    bottom: 0;
    top: 0;
    display: block;
    background-color:rgba(00, 00, 00, 1.0);
    }
    </style>
    </head>
    <body>

    <video id="video" width="400" height="224" controls>
    <!--<source src="video_for_banner.mp4" type="video/mp4">-->
    </video>

    <script>
    var video = document.getElementById('video');
    video.addEventListener('canplaythrough', function() {
    this.pause();
    });
    video.src = getUrlParam('video1');


    document.getElementById('video').onclick = function() {
    if (video.paused && ! video.ended) {
    video.play();
    video.setAttribute("controls", "controls") ;
    return;
    }
    window.open(getUrlParam("link1"));
    homeExpandableMobileBannerAPI.close();
    };

    document.body.addEventListener('click', function (event) {
    if (event.target.tagName.toLowerCase() !== 'body') {
    return;
    }
    onCLickBody()
    }, true);

    function onCLickBody(){
    window.open(getUrlParam("link1"));
    homeExpandableMobileBannerAPI.close();
    }
    </script>
    </body>
    </html>


×
×
  • Create New...