Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/77.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 如何在链接之前在iframe源代码中添加http?_Jquery_Html_Iframe - Fatal编程技术网

Jquery 如何在链接之前在iframe源代码中添加http?

Jquery 如何在链接之前在iframe源代码中添加http?,jquery,html,iframe,Jquery,Html,Iframe,我使用的是JSON(HTML源代码)并包含iframe,其源代码类似于 <iframe src="//www.youtube.com/embed/b34jsdg" height="360" width="640" allowfullscreen="" frameborder="0"></iframe><br> 我无法在www.youtube.com/embed/b34jsdg链接和使用此查询之前添加http <script>$

我使用的是JSON(HTML源代码)并包含iframe,其源代码类似于

    <iframe src="//www.youtube.com/embed/b34jsdg" height="360" width="640" allowfullscreen="" frameborder="0"></iframe><br>

我无法在www.youtube.com/embed/b34jsdg链接和使用此查询之前添加http

    <script>$('iframe').each(function (){var a = 'https://'+$(this).attr('src');$(this).attr('src',a);});</script>
$('iframe')。每个(函数(){var a='https://'+$(this.attr('src');$(this.attr('src',a);});

使用jQuery时,请确保在修改文档之前,您正在等待文档准备就绪

$(document).ready(function(e){
  // Your code here
});
此外,无论何时从服务器返回前缀为“//”的链接(例如在iframe中),该内容都将通过页面加载的任何协议加载。因此,“//www.google.com”在从https://somewebsite.com加载的iframe中,该iframe也将通过https加载其内容。因此iframe将加载https://www.google.com