【易优技巧】视频模型下实现视频地址以第三方跳转的方法

摘要: 如何将视频mp4直接用地址来实现前端点击播放栏目跳转到第三方链接(该链接)的方法。这样的目的是为了节省本服务器流量的压力。也能够用权限来控制是否权限内能够跳转这摘要: 如何将视频mp4直接用地址来实现前端点击播放栏目跳转到第三方链接(该链接)的方法。这样的目的是为了节省本服务器流量的压力。也能够用权限来控制是否权限内能够跳转这

如何将视频mp4直接用地址来实现前端点击播放栏目跳转到第三方链接(该链接)的方法。这样的目的是为了节省本服务器流量的压力。也能够用权限来控制是否权限内能够跳转这个地址。如图操作方法

QQ_1739546796119.png


前端的话只需将view_media_play.htm页面里面的内容改为以下代码即可:(不同的效果)

第一个是:



<!DOCTYPE html>

<html>

<head>

<meta charset="utf-8">

<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">

<title>正在跳转···</title>

<meta name="description" content="" />

<meta name="keywords" content="" />

  <style>

        /* 确保页面和body占据整个视口并居中内容 */

        html,

        body {

            height: 100%;

            margin: 0;

            display: flex;

            justify-content: center;

            align-items: center;

        }


        /* 对a标签进行样式设置,可根据需求调整 */

        a {

            display: inline-block;

            padding: 15px 30px;

            <!-- background-color: #007BFF; -->

            color: white;

            text-decoration: none;

            border-radius: 5px;

            font-size: 18px;

            text-align: center;

        }

    </style>

</head>

<body>

{eyou:videoplay aid='$eyou.field.aid' autoplay='off' id='video'}

    <a href="{$video.file_url}" {$video.id} loop='loop'>正在跳转<span id="countdown"></span></a>

  

    {$video.hidden}

{/eyou:videoplay} 


<script>

window.onload = function () {

    const link = document.querySelector('a');

    const countdownElement = document.getElementById('countdown');

    let countdown = 10;

    const countdownInterval = setInterval(() => {

        countdownElement.textContent = `倒计时 ${countdown} 秒`;

        countdown--;

        if (countdown < 0) {

            clearInterval(countdownInterval);

            if (link) {

                const url = link.href;

                window.location.href = url;

            }

        }

    }, 1000);

};

</script>

</body>

</html>


效果图:

QQ_1739547168606.png


JS代码说明:

<script>

window.onload = function () {

    const link = document.querySelector('a');

    const countdownElement = document.getElementById('countdown');

    let countdown = 10;

    const countdownInterval = setInterval(() => {

        countdownElement.textContent = `倒计时 ${countdown} 秒`;

        countdown--;

        if (countdown < 0) {

            clearInterval(countdownInterval);

            if (link) {

                const url = link.href;

                window.location.href = url;

            }

        }

    }, 1000);

};

</script>


  let countdown = 10;    这句话中间的10说明:倒计时10秒

   }, 1000);   这中间的1000 说明:1秒后开始倒计时(1000等于1秒)


第二种效果是没有倒计时的效果:


QQ_1739547365058.png



代码如下:



<!DOCTYPE html>

<html>

<head>

<meta charset="utf-8">

<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">

<title>正在跳转···</title>

<meta name="description" content="" />

<meta name="keywords" content="" />

  <style>

        /* 确保页面和body占据整个视口并居中内容 */

        html,

        body {

            height: 100%;

            margin: 0;

            display: flex;

            justify-content: center;

            align-items: center;

        }


        /* 对a标签进行样式设置,可根据需求调整 */

        a {

            display: inline-block;

            padding: 15px 30px;

            <!-- background-color: #007BFF; -->

            color: white;

            text-decoration: none;

            border-radius: 5px;

            font-size: 18px;

            text-align: center;

        }

    </style>

</head>

<body>

 {eyou:videoplay aid='$eyou.field.aid' autoplay='off' id='video'}

        <a href="{$video.file_url}" {$video.id} loop='loop'>正在跳转中····</a>

        {$video.hidden}

    {/eyou:videoplay}


<script>

window.onload = function () {

    const link = document.querySelector('a');

    const countdownElement = document.getElementById('countdown');

    let countdown = 3;

    const countdownInterval = setInterval(() => {

        countdownElement.textContent = `倒计时 ${countdown} 秒`;

        countdown--;

        if (countdown < 0) {

            clearInterval(countdownInterval);

            if (link) {

                const url = link.href;

                window.location.href = url;

            }

        }

    }, 3000);

};

</script>

</body>

</html>


JS说明:


<script>

window.onload = function () {

    const link = document.querySelector('a');

    const countdownElement = document.getElementById('countdown');

    let countdown = 3;

    const countdownInterval = setInterval(() => {

        countdownElement.textContent = `倒计时 ${countdown} 秒`;

        countdown--;

        if (countdown < 0) {

            clearInterval(countdownInterval);

            if (link) {

                const url = link.href;

                window.location.href = url;

            }

        }

    }, 3000);

};

</script>


其中

   }, 3000);   3000为3秒后跳转


第三种是。没有样式直接跳转


QQ_1739547533733.png


代码如下:



<!DOCTYPE html>

<html>

<head>

<meta charset="utf-8">

<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">

<title>正在跳转···</title>

<meta name="description" content="" />

<meta name="keywords" content="" />

</head>

<body>

{eyou:videoplay aid='$eyou.field.aid' autoplay='off' id='video'}

    <a href="{$video.file_url}" {$video.id} loop='loop'>点击跳转</a>

    {$video.hidden}

{/eyou:videoplay} 


<script>

    // 等待页面加载完成

    window.onload = function () {

        // 直接选择第一个 a 标签

        const link = document.querySelector('a');


        // 延迟 3 秒后跳转,可根据需要调整时间

        setTimeout(function () {

            if (link) {

                // 获取 a 标签的 href 属性值

                const url = link.href;

                // 执行跳转

                window.location.href = url;

            }

        }, 3000);

    };

</script>

</body>

</html>




文章版权及转载声明:

编辑:小秋同学本文地址:https://www.qiuhai.com/study/5687.html发布于 02-14 23:23:29
文章转载或复制请以超链接形式并注明出处学习吧_一个不错的学习网站
本站文章如没有特殊说明,均采集网上收集,若要转载请务必注明出处,尊重他人劳动成果共创和谐网络环境。 声明:某些文章来源于网络,所采集的到信息本站只为传递信息和分享,不做任何双方证明,也不承担任何法律责任。 文章内容若侵犯你的权益,请联系本站客服删除!

觉得文章有用就施舍一下文章作者

支付宝施舍

微施舍

阅读
分享

发表评论
加载中~