Restrict additional pagehead in sharepoint popup window
hi i have added additionalpagehead in sharepoint which will run a javascript functions to show some texts. It is working fine in all the sharepoint pages but it is working in sharepoint popup window also. How can i restrict it from po开发者_如何学Cpup windows.
Try to use this code inside PlaceHolderAdditionalPageHead placeholder:
<script type="text/javascript">
var IsDlg = (/[\\?&]IsDlg=([^&#]*)/.test(window.location.href));
if (!IsDlg)
{
// your javascript code ...
}
</script>
An alternative to Alex's answer is this: You can add an if condition to your function so that it tests if the current document is loaded in a iframe (which how Sharepoint displays its popup window/modal dialog), before doing that is does.
John Chapman contributed this code here:
var isInIFrame = (window.location != window.parent.location) ? true : false
精彩评论