Fast way of opening a link in a modal dialog in SP2010
June 26th, 2012 | Categories: SharePoint 2010
A lot of times I prefer to open a link in a modal dialog instead of new window or even same window. SP.UI has a function to open a modal dialog, but a lot of times you don’t need to create that function. A lot of times I just prefer to use SharePoint’s built-in function. So to open a page in a modal dialog just change your link from
your link name
to
your link name
This code ofcourse works in SharePoint designer and other areas in SharePoint where you have SP.UI loaded. It also doesn’t work in rich text fields in SharePoint as the JavaScript gets filtered out.
I’ve tried this in my page, but SPD keeps stripping all the onclick code, and leaving just href attribute intact. Is there any way around this?
Sometimes editing without design view helps… but only sometimes…
I did the same for publishing sharepoint web page. But when I edit the page and put the text in anchor tag with the code similar to above to open the window in new dialog box, and make it save, the onclick event of the tag is automatically removed from the page. I did not understand why it is happening? And strange, it worked on another page.
In publishing page scripts are removed, because it could present a security issue.
works perfect. Thank you very much.