window open using content editor in SharePoint
This is very common requirement in web world to open any link in a new window. The simplest approach is to use JavaScript to implement same. The same is applicable in SharePoint as well. There are different gateways you can implement JavaScript in SharePoint pages. You can use master page, layout page or any OTB component for the same. Every way has some pros and cons. However the simplest way is to use SharePoint OTB web part i.e. Content Editor web part.
The advantage of using Content Editor web part is that you can easily integrate it in any SharePoint pages by just adding this from the OTB web part gallery. You have option to hide this content editor web part as well. Once hide, end user not able to see the content editor control inside the pages, however the script/code actually work as expected.
Ok, let’s see how to implement in simple way to open the new window using Content Editor web part. Open the SharePoint page using IE and click on EDIT Page option. In other words you are going ahead to check-out the page for editing. Click on Add Web Part link and select the Content Editor web part from the web part gallery. Once added, it will take place inside the page.
Click on Edit and select Modify Web part. Content editor web part edit dialog will be open up. Click on Source Editor button and the text window will be open up. Here you need to put your script details to work.

JavaScript Window showModalDialog Code:
<div id=path style=”padding-top:10px;”>
<a onclick=”javascript:void(window.showModalDialog(‘/popuppages/Pages/MyPopupPage1.aspx?EqGroupName=CTESNOX&pReportTitle=CTE, SNOx’,”,’scroll:no;status:no;dialogWidth:800px;dialogHeight:600px;‘))”>CTE</a>
<br>
<a onclick=”javascript:void(window.showModalDialog(‘/popuppages/Pages/MyPopupPage2.aspx?EqGroupName=TRACQUE&pReportTitle=Trattamento Acque’,”,’scroll:no;status:no;dialogWidth:800px;dialogHeight:600px;’))” >Trattamento Acque</a>
</div>
Now click on Apply and ok. Once it is saved, and you are back into the SharePoint page, clicking on the associated link, it will open the url in a new window. Make it simple
![]()
At the conclusion, few things you may consider on the example code. How I passed the query parameter value inside the JavaScript. Instead of the hard code value, you can pass the dynamic value. To pass the dynamic value, use the JavaScript variable or capture the value at run time. You can push as many scripting code inside the Content Editor. No matters how long it is
