如何在ContentEditorWebPart的src中添加一个带有QueryString的iFrame? [英] How to put an iFrame with a QueryString appended in its src in the ContentEditorWebPart?

查看:65
本文介绍了如何在ContentEditorWebPart的src中添加一个带有QueryString的iFrame?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

I have a SharePoint site Page in which i need to put an iFrame element to display a web page.To achieve that I wrote some html and javascript within CDATA tag inside the Content section of a ContentEditorWebPart as follows.







<Content xmlns="http://schemas.microsoft.com/WebPart/v2/ContentEditor">
<![CDATA[
<iframe width="100%" id="mySitecontainer" src="https://mywebsite/Login.aspx?loguser=" frameborder="0" > </iframe>
<script type="text/javascript">
    var lusr = getLoggedUser();
    var requiredUrl = "https://mywebsite/Login.aspx?loguser=" + lusr;
    $('#mySitecontainer').attr('src',requiredUrl);
</script>
]]>
</Content>







Here the 

getLoggedUser() function is inside an external js file for which I have added a reference earlier.Now the problem is the above script is not working sometimes, especially whenever I refresh the SharePoint site page in the browser and the src of the above iFrame element is being rendered without any querystring parameter(loguser in this case). Can someone help me where I did wrong here?

推荐答案

('#mySitecontainer')。attr('src',requiredUrl);
< / script>
]]>
< /内容 >
('#mySitecontainer').attr('src',requiredUrl); </script> ]]> </Content>







Here the 

getLoggedUser() function is inside an external js file for which I have added a reference earlier.Now the problem is the above script is not working sometimes, especially whenever I refresh the SharePoint site page in the browser and the src of the above iFrame element is being rendered without any querystring parameter(loguser in this case). Can someone help me where I did wrong here?


这篇关于如何在ContentEditorWebPart的src中添加一个带有QueryString的iFrame?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆