zoukankan      html  css  js  c++  java
  • js获取URL请求参数与改变src

    js实现:

    <script>
    function GetQueryString(name) {
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
    var r = window.location.search.substr(1).match(reg);
    if(r != null) return unescape(r[2]);
    return null;
    }

    window.onload=function() {
    var img=document.getElementById("type");

    img.setAttribute("src","img/tiche/"+GetQueryString("carmodel")+".jpg");
    }

    </script>
    <div style="margin-top:40px">
    <img src="" width="100%">
    <img src="" width="100%">
    <img id="type" src="" width="100%">
    </div>

    <html>
    <head>
    <meta name="renderer" content="ie-stand|ie-comp|webket">
    <meta http-equiv="X-UA-Compatible" content="IE=8,IE=9,IE=10" />
    <script type="text/javascript">

    window.onload=function(){
    var codeId = GetQueryString('id');
    // alert(codeId);
    var img=document.getElementById("wu");
    img.setAttribute("src","http://10.0.1.9:6713/mag/hls/"+codeId+"/0/live.m3u8");

    var player = videojs("example-video");
    player.play();
    }
    </script>
    <SCRIPT>
    function GetQueryString(name)
    {
    var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
    var r = window.location.search.substr(1).match(reg);
    if(r!=null)return unescape(r[2]); return null;
    }
    </SCRIPT>
    <link href="/cxfvp/static/css/video-js.css" rel="stylesheet" type="text/css">
    <script src="/cxfvp/static/js/video.min.js" type="text/javascript"></script>
    <script src="/cxfvp/static/js/videojs-contrib-hls.js" type="text/javascript"></script>
    </head>
    <body>
    <table id="contentTable" class="table table-striped table-bordered table-condensed">
    <thead>
    <tr>
    <th>视频</th>
    </tr>
    </thead>
    <tbody>
    <tr>
    <td>
    <video id="example-video" class="video-js"
    width="1200" height="750" >
    <source id="wu" src="http://10.0.1.9:6713/mag/hls/codeId/0/live.m3u8" type="application/x-mpegURL">
    </video>
    </td>
    </tr>
    </tbody>
    </table>
    </body>
    </html>

  • 相关阅读:
    酷狗大数据平台架构是如何重构的
    分层架构,前后端分离有啥坏处?
    Redis快速入门及应用
    Kafka不只是个消息系统
    提高代码质量:如何编写函数
    jquery 回车事件
    程序员的薪资是如何确定出来的?
    HTTP 错误 500.21
    制作手机浏览器显示格式的HTML页面
    操作必须使用一个可更新的查询。
  • 原文地址:https://www.cnblogs.com/wudage/p/10082656.html
Copyright © 2011-2022 走看看