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>

  • 相关阅读:
    python中获取python版本号的方法
    Unity3D 的大场景内存优化
    Unity中的内存泄漏
    HDR和bloom效果的区别和关系
    用TexturePacker打图集用于UGUI中
    Lua的闭包详解(终于搞懂了)
    深入浅出!从语义角度分析隐藏在Unity协程背后的原理
    Unity3D导入3DMax模型缩放单位问题深入分析
    Unite 2017 | 从《闹闹天宫》看MOBA游戏里的网络同步技术
    Unity声音-音源组件
  • 原文地址:https://www.cnblogs.com/wudage/p/10082656.html
Copyright © 2011-2022 走看看