indexOf(“http”)在http和https上匹配

indexOf("http") matches on http and https

本文关键字:http https indexOf      更新时间:2024-06-06

我有以下代码,

var protocol = jQuery('script[src*="kaltura"]').attr("src");
protocol.toLowerCase().indexOf("http");

问题是indexOf在http和https上匹配。我如何才能只在http上匹配它?

假设您只想检查网站的协议,请检查http://:

protocol.toLowerCase().indexOf("http://");