[英]Hardcoded binding in iframe's src to a Kaltura video works. But, binding it to a variable does not work in IE
I have a SharePoint site that loads angularjs on it.我有一个加载 angularjs 的 SharePoint 站点。 On one of my sites, I'm trying to show an iframe with an embedded video from Kaltura.
在我的一个网站上,我试图展示一个带有来自 Kaltura 的嵌入式视频的 iframe。 See below for snippets of my code.
请参阅下面的代码片段。
NOTE: The embed video below is NOT the actual video because of confidentiality reasons.注意:出于保密原因,下面的嵌入视频不是实际视频。
JavaScript file: JavaScript 文件:
var embedVideoLink = 'https://mediaspace.company.com/embed/secure/iframe/entryId/0_dfnoklj0/uiConfId/12345678';
$('<iframe>')
.attr('id', 'cf_iframe_video')
.attr('src', embedVideoLink)
.attr('frameborder', 0)
.attr('allow', 'autoplay *; fullscreen *; encrypted-media *')
.attr('allowfullscreen', 'allowfullscreen')
.attr('width', '100%')
.attr('height', '350px')
.appendTo('#cf_iframe_video_container');
HTML File: HTML 文件:
<div id="cf_iframe_video_container" class="row embed-responsive embed-responsive-16by9">
The above code works perfectly fine in Chrome and Edge, but NOT in IE.上面的代码在 Chrome 和 Edge 中运行良好,但在 IE 中不行。 I keep seeing "Error kWdiget never ready" on IE.
我一直在 IE 上看到“错误 kWdiget 从未准备好”。
In order to make it work in IE11, I bind the src with the hardcoded value like this:为了使其在 IE11 中工作,我将 src 与硬编码值绑定,如下所示:
.attr('src', 'https://mediaspace.company.com/embed/secure/iframe/entryId/0_dfnoklj0/uiConfId/12345678')
But I cannot do that because the embed link is stored somewhere else and users are free to replace it.但我不能这样做,因为嵌入链接存储在其他地方,用户可以自由替换它。 Am I missing something in here?
我在这里错过了什么吗? What can you suggest I do so I can make it work with IE11 as well?
你能建议我做什么,这样我也可以让它与 IE11 一起工作?
I refactored my code.我重构了我的代码。 I instead took the whole embedCode from User input.
相反,我从用户输入中获取了整个 embedCode。 Sample expected input:
样本预期输入:
<iframe src="https://mediaspace.company.com/embed/secure/iframe/entryId/0_hx1rzwia/uiConfId/12345678" frameborder="0" class="kmsembed" width="100%" height="350px" allow="autoplay *; fullscreen *; encrypted-media *" allowfullscreen="allowfullscreen"></iframe>
Then, my js code looks like this:然后,我的 js 代码如下所示:
var embedCode = curItem.checklist; //Taken from User Input in a SharePoint List
embedCode = embedCode.replace(/>/g, ">").replace(/</g, "<").replace(/"/g, '\\"').replace(/:/g, ':').replace(/\\/g,'');
var embeddedIframe = '';
embeddedIframe = common.decodeHTML(embedCode);
$scope.embeddedVideo = $sce.trustAsHtml(embeddedIframe);
Finally, the HTML file looks like this:最后,HTML 文件如下所示:
<div id="cf_iframe_video_container" class="row embed-responsive embed-responsive-16by9" ng-bind-html="embeddedVideo">
It now works as expected.它现在按预期工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.