Add New SharePoint List Item As Pop Up Instead Of Opening In New Page

Problem Statement

 
Add new SharePoint list item as Pop up instead of opening in new page.
 
Create a SharePoint list with column Title, Name, City, Address.
 
Click on New Item – Copy the url of new item upto http://Site Name /Teams/Lists/Listname/NewForm.aspx?
 
Make sure URL should be copied up to http://……..NewForm.aspx?
  • Edit the Sharepoint list by using Gear icon on Top Right side
  • Click on Insert button on Top Left side then select Media and Content, then click on Script Editor and click Add button on right
  • Click on edit snippet
  • Paste below javascript code and click insert and the stop editing the page,
    1. <a href='javascript:displayLayover("http://SitenameTeams/Lists/List/NewForm.aspx?'>New Item</a>  
    2. <script type="text/javascript">  
    3.    function displayLayover(url) {  
    4.       var options = SP.UI.$create_DialogOptions();  
    5.       options.url = url;  
    6.       options.dialogReturnValueCallback = Function.createDelegate(nullnull);  
    7.       SP.UI.ModalDialog.showModalDialog(options);  
    8.    }  
    9. </script>  
Happy Coading.....:)