How do you create a popup in sharepoint within a content editor?
I need to create a popup in sharepoint 2007 by clicking on a link within a content editor.
thanks
April 18th, 2013 2:56pm

Hi Alexxuzd,

In MOSS you can leverage the core.js function, commonShowModalDialog. To use it, open your SharePoint site, and add a Content Editor Web Part with this code:

<a href="javascript:openInModalDialog()">CLICK HERE</a>

 <script type="text/javascript">
function openInModalDialog()
{
  var url = "/Lists/Calendar/Calendar.aspx";
  commonShowModalDialog(url,"resizable: no; status:no; scroll: no; help: no; center: yes; dialogwidth:800px; dialogHeight:500px;",RetrieveItemValue);
}
</script>

Free Windows Admin Tool Kit Click here and download it now
April 18th, 2013 5:20pm

Hi,

In SP 2010, Select Contents in CEWP, Format--> Html Source in the ribbon,
Add the javacript code 
<script type="text/javascript">      function OpenDialog(URL) {          var NewPopUp = SP.UI.$create_DialogOptions();          NewPopUp.url = URL;          NewPopUp.width = 700;          NewPopUp.height = 350;         SP.UI.ModalDialog.showModalDialog(NewPopUp);      }  script> <a onlick=javascript:OpenDialog(/sites/alr/SitePages/Reservation.aspx) >Show</a>-To Make it Server relative.
So that Dialog box opens anywhere in site collection
April 18th, 2013 10:14pm

Hi,

Copy paste below code in your CEWP and see the magic:

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>jQuery Popup Dialog - Click</title>
<style type="text/css">
#overlay {
;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: #000;
filter:alpha(opacity=70);
-moz-opacity:0.7;
-khtml-opacity: 0.7;
opacity: 0.7;
z-index: 100;
display: none;
}
.content a{
text-decoration: none;
}
.popup{
width: 100%;
margin: 0 auto;
display: none;
;
z-index: 101;
}
.content{
min-width: 600px;
width: 600px;
min-height: 150px;
margin: 100px auto;
background: #f3f3f3;
;
z-index: 103;
padding: 10px;
border-radius: 5px;
box-shadow: 0 2px 5px #000;
}
.content p{
clear: both;
color: #555555;
text-align: justify;
}
.content p a{
color: #d91900;
font-weight: bold;
}
.content .x{
float: right;
height: 35px;
left: 22px;
;
top: -25px;
width: 34px;
}
.content .x:hover{
cursor: pointer;
}
</style>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.js"></script>
<script type='text/javascript'>
$(function(){
var overlay = $('<div id="overlay"></div>');
$('.close').click(function(){
$('.popup').hide();
overlay.appendTo(document.body).remove();
return false;
});
$('.x').click(function(){
$('.popup').hide();
overlay.appendTo(document.body).remove();
return false;
});
$('.click').click(function(){
overlay.show();
overlay.appendTo(document.body);
$('.popup').show();
return false;
});
});
</script>
</head>
<body>
<div class='popup'>
<div class='content'>
<img src='http://www.developertips.net/demos/popup-dialog/img/x.png' alt='quit' class='x' id='x' />
<p>
Here is the popup you wanted !!!!
<br/>
<br/>
<a href='' class='close'>Close</a>
</p>
</div>
</div>          
<div id='container'>
<a href='' class='click'><h2><b>Click Here to See Popup! </b></h2></a> <br/>
</div>
</body>
</html>

Hope this helps:

Regards

Ankur

Free Windows Admin Tool Kit Click here and download it now
April 19th, 2013 4:47am

Thanks for the above...it was so helpfull.
July 31st, 2014 12:43pm

Hi Alexxuzd,

In MOSS you can leverage the core.js function, commonShowModalDialog. To use it, open your SharePoint site, and add a Content Editor Web Part with this code:

<a href="javascript:openInModalDialog()">CLICK HERE</a>

 <script type="text/javascript">
function openInModalDialog()
{
  var url = "/Lists/Calendar/Calendar.aspx";
  commonShowModalDialog(url,"resizable: no; status:no; scroll: no; help: no; center: yes; dialogwidth:800px; dialogHeight:500px;",RetrieveItemValue);
}
</script>		
Free Windows Admin Tool Kit Click here and download it now
March 11th, 2015 2:10pm

Hi Alexxuzd,

below is the code

<script type="text/javascript">

     function openBasicDialog(tUrl, tTitle) {
         var options = {
             width: 1200,
             height: 700,
             url: tUrl,
             title: tTitle
         };
         SP.UI.ModalDialog.showModalDialog(options);
     }

 </script>
 <a href="#" onclick="openBasicDialog('yourpageurl','modal dialog box');">Open POPUP</a>

August 14th, 2015 3:27am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics