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?