getting a popup for a "Rich Text label field" field on catalog item

NiloferS
Tera Contributor

NiloferS_0-1721121933457.png

I have created a "rich text field" called "click here to download requisition form". it is suppose to download a pdf file.

But before downloading it is giving me this popup to leave site. when i click on leave the pdf is getting downloaded and when i click on cancel its not getting downloaded. 

How to remove this popup and let the user download pdf as soon as they click on the variable.

1 ACCEPTED SOLUTION

Amit Verma
Kilo Patron
Kilo Patron

Hi @NiloferS 

 

Setting the Open Link in New Window should do the trick.

 

AmitVerma_0-1721124789986.png

 

Thanks and Regards

Amit Verma


Please mark this response as correct and helpful if it assisted you with your question.

View solution in original post

5 REPLIES 5

HrishabhKumar
Kilo Sage

Hi @NiloferS ,

Found a step by step resolution to this, try it and see if it helps:

To resolve this issue and ensure that the PDF is downloaded directly when clicking on the rich text field without showing the "leave site" popup, you can use JavaScript to handle the click event and trigger the download. Here's a step-by-step guide on how to do it:

Step 1: Host the PDF File

Ensure the PDF file is hosted on a server that you can access via a direct URL.

Step 2: Create a UI Script

  1. Navigate to System UI > UI Scripts.
  2. Click on "New" to create a new UI Script.
  3. Name the script appropriately, e.g., "Download PDF Script".
  4. In the Script field, add the following JavaScript code:

 

 

​function downloadPDF(url) {
    var link = document.createElement('a');
    link.href = url;
    link.download = url.substring(url.lastIndexOf('/') + 1);
    document.body.appendChild(link);
    link.click();
    document.body.removeChild(link);
}

 

 

  1. Save the UI Script.

Step 3: Add the Rich Text Field

When creating or editing the form containing the rich text field, add the following HTML with an onclick event that calls the downloadPDF function:

 

 

<a href="#" onclick="downloadPDF('https://example.com/path/to/your/file.pdf'); return false;">Click here to download requisition form</a>

 

 

Replace https://example.com/path/to/your/file.pdf with the actual URL of your PDF file.

Thanks.

Hope this helps.

If my response turns useful, mark it helpful and accept solution.

 

Sandeep Rajput
Tera Patron
Tera Patron

@NiloferS In your hyperlink please add the target attribute as _blank. Here is an example of the sample link 

 

<a href="https://www.w3schools.com" target="_blank">Visit W3Schools</a>

 

Please mark the response helpful and accepted solution if it manages to address your question.

Amit Verma
Kilo Patron
Kilo Patron

Hi @NiloferS 

 

Setting the Open Link in New Window should do the trick.

 

AmitVerma_0-1721124789986.png

 

Thanks and Regards

Amit Verma


Please mark this response as correct and helpful if it assisted you with your question.

Ramya95
Tera Contributor

Hi @Amit Verma 
Could you please let us know where exactly we can set this Open link in... drop down.