open attachment link in a new tab in allitems.aspx

ameneh maleki 46 Reputation points
2024-09-14T07:46:06.7+00:00

Hi

I create workflow to show attachment link as a column in allitems.aspx.

I use below link to open attachment link in pop-up window in allitems.aspx:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js" type="text/javascript"></script><script type="text/javascript">

 $(document).ready(function(){

     //In SharePoint OOTB list view, all 'td' will have this class 'ms-cellstyle'

     $(".ms-vb2 a").click(function () {  

         var currentURL = $(this).attr('href');

         var onclickVal = $(this).attr('onclick') || '';

         if(onclickVal == '') {

            currentURL = "javascript:ModalDailog('"+currentURL+"')";          

            $(this).attr('onclick', 'empty');    

            $(this).attr('href', currentURL);       

         }

     });

 });

 

 //Function to open url in Modal Dailog

 function ModalDailog(urlvalue) {   

     var options = {

         url: urlvalue,

         width: 800,              

         allowMaximize: true,

         showClose: true,    

         dialogReturnValueCallback: silentCallback

     };

     SP.UI.ModalDialog.showModalDialog(options);

 }

 function silentCallback(dialogResult, returnValue) {

 }

 function refreshCallback(dialogResult, returnValue) {

     SP.UI.Notify.addNotification('Operation Successful!');

     SP.UI.ModalDialog.RefreshPage(SP.UI.DialogResult.OK);

 }

 </script>

 

I add this code to CEWB in AllItems.aspx and it’s work properly.

But this function dosen’t work in datasheet view!

How I can open attachment link in a new tab or in pop-up window in datasheet view in sharepoint list?

SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
10,685 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.