JS error: 'function' is undefined

I have a sharepoint web part page with a CEWP in it containing the code below but I get the following error and can't figure out why.

SCRIPT5009: 'OpenPopup' is undefined

Here's the page: http://isaac.issharepoint.com/ICTT/Shared%20Documents/dataTables.aspx
Any idea why?

I have the below inside of a CEWP on a webpart page in SP 2013
<!DOCTYPE html>

<html>
<head>
	<title></title>
	<script type="text\javascript">
		function OpenPopup() {
		var url = "/modalTable.aspx";
    		var options = {
        		url: url,
        		title: 'Modal Example',
        		allowMaximize: false,
       	 		showClose: true,
        		width: 600,
        		height: 500,
        		dialogReturnValueCallback: refreshCallback
    			}
   		 SP.UI.ModalDialog.showModalDialog(options);
		}


		function refreshCallback()
		{
			alert("HELLO WORLD");
		}
	</script>
</head>

<body>
	<span>Click to open datatable in modal box</span>
	<input type="button" value="Modal Box" onclick="OpenPopup();" />
</body>

</html>

Open in new window

LVL 5
IsaacSharePoint Client Side DeveloperAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ronak PatelCommented:
Hi TheInnovator,

I think on the page load it is calling "MoveSiteTitle" function, which is not present on the page.
You need to add the definition of "MoveSiteTitle" function to the page.

Please refer attached screenshot.

Regards,
Ronak

error.png
0
IsaacSharePoint Client Side DeveloperAuthor Commented:
'MoveSiteTitle' is not something I created or am calling.  That's a SharePoint 2010 thing.  The only error that I'm getting is SCRIPT5009: 'OpenPopup' is undefined
0
IsaacSharePoint Client Side DeveloperAuthor Commented:
I got it to work by modifying the code to this

<!DOCTYPE html>

<html>
<head>
	<title></title>

<script type="text/javascript">

    function dialogfunction(pageUrl) {

    var options = { url: pageUrl, width: 800, height: 600 };

    SP.SOD.execute('sp.ui.dialog.js', 'SP.UI.ModalDialog.showModalDialog', options);

    }

</script>

</head>

<body>
	<span>Click to open datatable in modal box</span>
	<input type="button" value="Modal Box" onclick="javascript:dialogfunction('modalTable.aspx');" />
</body>

</html>

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
IsaacSharePoint Client Side DeveloperAuthor Commented:
Found a solution that worked.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.