# Pop Up On Load SharePoint 2013

I am trying to get a modal to appear when the site loads.

• I created a site page called Disclaimer.aspx and stored it in the Site Pages document library.
• I created a text document called popup.txt and stored it in my Shared Documents.
• I added a content editor webpart to my home screen and linked it to the popup.txt file

Onload the page displays the modal however, the Disclaimer.aspx page isn't showing. I am getting a Error: An unexpected error has occurred

Contents of popup.txt:

 <SharePoint:ScriptLink ID="ScriptLink21" Name="sp.js" runat="server" OnDemand="true"

Localizable="false" />

<script type="text/ecmascript">

function ShowDialog() {

var options = {
url: '../SitePages/Disclaimer.aspx',
height: 500,
};

SP.UI.ModalDialog.showModalDialog(options);
}
</script>


I tried the code with the full path and I get the same error.

• Try with adding script editor webpart on page and add your modal pop up script in it. remove content editor webpart. – SP Developer Sep 20 '16 at 18:01
• The CEWP method should work. But, I would not be calling the same page modal from within the page, It sounds recursive to me. – Ransher Singh Sep 20 '16 at 18:14
• There's a correlation ID. Can you check what's the error in the uls logs? My guess is that's related to the target page itself, not the way you open the page. – Steve B Sep 22 '16 at 15:21

You should first ensure that the Disclaimer.aspx is not a wiki page it should be web part page to avoid An unexpected error has occurred ,

If everything is OK , try to add the following code at your CEWP

<a href="#" onclick="javascript:SP.UI.ModalDialog.showModalDialog({ url: '../SitePages/Disclaimer.aspx', title: 'Disclaimer' }); return false;"  >Click Here</a>


Also, you can try to use the following code

 <script>
function openDialog(pageUrl) {
var options = {
url: pageUrl,
title: 'Title of the Dialog',
allowMaximize: false,
showClose: true,
width: 500,
height: 500
};
SP.SOD.execute('sp.ui.dialog.js', 'SP.UI.ModalDialog.showModalDialog', options);
}

</script>
<a href="#" onclick="openDialog('http://path/SitePages/Disclaimer.aspx');">Disclaimer</a>


Both samples have been worked for me without issue ,