Looking to see how I could create a button on a SharePoint page that would create a new site. I know this can be done through Site Actions and a couple more clicks, but I want to make it intuitive for the user to just click a button and essentially do the same thing as it would navigating through Site Actions...
1 Answer
You should try to do the following
- Edit your page that you need to add the link button .
- Add content Editor.
- From the above ribbon click on Edit Source.
- Add the following code to create a link to open in the model dialog to create a new website.(or add your final link that navigating through Site Actions)
<script> function openDialog(pageUrl) { var options = { url: pageUrl, title: 'Create New Site', allowMaximize: false, showClose: true, width: 700, height: 500 }; SP.SOD.execute('sp.ui.dialog.js', 'SP.UI.ModalDialog.showModalDialog', options); } </script> <a onclick="openDialog("http://yourrootsite/_layouts/15/newsbweb.aspx");" href="#">Create New Site</a>
OutPut
Check also the detail steps that matched with your situation at Open a link via Modal Dialog in SharePoint
-
Hi! This doesn't seem to be working for me. Maybe because this is 2013 and I am using 2010? Is there another way? Thank you!– JackieAug 19, 2016 at 15:32
-
what's your issue now my bro ?! you only need to put your final link URL and I tried in both 2010 and 2013 and worked properly Aug 19, 2016 at 16:03
-
I changed the final link URL and tested it but the link doesn't do anything. I went back into the CEWP and it changed the whole thing to this: <script> function openDialog(pageUrl) { var options = { url: pageUrl, title: 'Create New Site', allowMaximize: false, showClose: true, width: 700, height: 500 }; SP.SOD.execute('sp.ui.dialog.js', 'SP.UI.ModalDialog.showModalDialog', options); } </script><a onclick="openDialog(" href="#">Create New Site</a>– JackieAug 19, 2016 at 16:12
-
try to use this in cewp var options = { url:'/_layouts/prjsetng.aspx', title:'Title, Description, and Icon', width:640, height:400 } SP.UI.ModalDialog.showModalDialog(options); Aug 19, 2016 at 16:26
-
I tried this and unfortunately it still isn't working. I do not have a TeamViewer but thanks for the help.– JackieAug 19, 2016 at 16:53