关于Not allowed to load local resource的问题
2017-09-04 23:02
711 查看
在浏览器里面,本来想将下面的黄色代码代码改成file,以为这样可以选择播放的文件,但是实际上是不行的,因为浏览器会保护,不允许载入如
C:\fakepath\testVideo.mp4这样的绝对路径,必须使用相对路径,将视频和网页文件放在一起,然后在网页输入文件名就可以正常播放
像下图
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>视频播放器</title> <script type="text/javascript"> function playOrPauseVideo() { var videoUrl = document.getElementById("videoUrl").value; console.log(videoUrl); var video = document.getElementById("video"); video.addEventListener("timeupdate",function() { var timeDisplay = document.getElementById("time"); timeDisplay.innerHTML = Math.floor(video.currentTime)+"/"+Math.floor(video.duration)+"(秒)"; },false); if(video.paused) { if (videoUrl != video.src) { video.src = videoUrl; b2c2 video.load(); }else { video.play(); } document.getElementById("playButton").value ="暂停"; }else { video.pause(); document.getElementById("playButton").value ="播放"; } } </script> </head> <body> <video id="video" width="400" height="300" autoplay loop="loop"> </video> <br /> 视频地址:<input type="text" id="videoUrl"/> <input id="playButton" type="button" onclick="playOrPauseVideo()" value="播放"/> <span id="time"></span> </body> </html>
相关文章推荐
- 解决 Not allowed to load local resource 问题
- 上传图片,Not allowed to load local resource,springboot上传
- 网页提示[Not allowed to load local resource: file://XXXX]错误
- Not allowed to load local resource
- not allowed to load local resource
- Not allowed to load local resource
- Chrome无法打开文件的错误 [Not allowed to load local resource: file://XXXX]
- 解决Android WebView中出现 Not allowed to load local resource:
- Chrome无法打开文件的错误 [Not allowed to load local resource: file://XXXX]
- android webview Not allowed to load local resource错误的解决办法
- android webview Not allowed to load local resource错误的解决办法
- Chrome无法打开文件的错误 [Not allowed to load local resource: file://XXXX]
- JS: Not allowed to load resource
- 使用chrome调试ajax加载本地文件的时候出现Failed to load resource: Origin null is not allowed by Access-Control-Allow
- 【解决】Mysql关于Host \'XXX\' is not allowed to connect to this MySQL server 的问题
- 关于tomcat不能启动的问题(NB:JAVA_HOME should point to a JDK not a JRE)
- 关于homebrew使用时遇到的问题: Error: Could not symlink bin/gdb/usr/local/bin is not writable.
- 解决mysql本地可访问,远程无法访问的问题 Host is not allowed to connect to this MySQL server
- mm_cvc-complex-type.3.2.2: Attribute 'local' is not allowed to appear in element 'ref'.