繁体   English   中英

检测 HTML5 视频是否为本地

[英]Detect if HTML5 video is local

请问如何检测视频源是本地的还是外部的

使用正则表达式检测视频源并将其定义为本地或外部的最佳方法是这样吗? => https?:\/\/

或者有这方面的 API 吗? 最佳做法是什么? 谢谢

谢谢你。

您可以将 URL 设置为锚点的href并检查其主机。

 const a = document.createElement('a'); a.href = '/local'; console.log(a.host === location.host); // internal a.href = 'https://example.com'; console.log(a.host, location.host);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM