var a = document.createElement("a"); a.href = "open360://192.168.0.110:8081/Web/RTSP/index.html?url="+encodeURIComponent("rtsp://admin:hz12345678hz@192.168.0.122:554/Streaming/Channels/101"); a.innerText='播放'; document.body.appendChild(a);
decodeURIComponent 解码
1 2 3 4 5 6 7 8 9 10 11 12 13
constparseQueryString = ()=>{ var json = {}; let url = location.href; var arr = url.substr(url.indexOf('?') + 1).split('&'); arr.forEach(item=>{ var tmp = item.split('='); json[tmp[0]] = tmp[1]; }); return json; }
var query = parseQueryString(); let src = decodeURIComponent(query.url);
<scripttype="text/javascript"> // Firefox, Google Chrome, Opera, Safari, Internet Explorer from version 9 functionOnInput (event) { alert ("The new content: " + event.target.value); } // Internet Explorer functionOnPropChanged (event) { if (event.propertyName.toLowerCase () == "value") { alert ("The new content: " + event.srcElement.value); } } </script>
// array like object var obj = { 0: 'a', 1: 'b', 2: 'c' }; console.log(Object.values(obj)); // ['a', 'b', 'c']
// array like object with random key ordering // when we use numeric keys, the value returned in a numerical order according to the keys var an_obj = { 100: 'a', 2: 'b', 7: 'c' }; console.log(Object.values(an_obj)); // ['b', 'c', 'a']
// getFoo is property which isn't enumerable var my_obj = Object.create({}, { getFoo: { value: function() { return this.foo; } } }); my_obj.foo = 'bar'; console.log(Object.values(my_obj)); // ['bar']
// non-object argument will be coerced to an object console.log(Object.values('foo')); // ['f', 'o', 'o']
// 点击事件change $('input[type=radio][name=myname]').change(function () { // 获取input radio选中值,方法一 var myvalue = $('input:radio[name="myname"]:checked').val(); // 获取input radio选中值,方法二 var myvalue = $(this).val(); });
解析 location URL 中参数
1 2 3 4 5 6 7 8 9 10
functiongetQueryVariable(variable) { var query = window.location.search.substring(1); var vars = query.split("&"); for (var i=0;i<vars.length;i++) { var pair = vars[i].split("="); if(pair[0] == variable){return pair[1];} } return(false); }
/** * 退出全屏 */ let exitFullscreen = function () { let el = parent.document; let cfs = el.cancelFullScreen || el.webkitCancelFullScreen || el.mozCancelFullScreen || el.exitFullScreen;