function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Joey HoJoey Ho 

Read Only iFrame within VF page

Hi,

 

I have a requirement where a visualforce page with standard controller of 'Case' displays a another 'Case' record within the same page using apex:iframe however this iframe can only be read-only, i.e. links within the iframe can't be clicked.

 

I know that we can set the apex:page to readonly="true" but that would than stop my engineers from being able to edit the content on that VF page.

 

How do I just make part of the page (or specifically the iframe component) only read-only within the VF page?

 

Thanks for your help.

 

Regards.

Joey.

Avidev9Avidev9
How about creatting a new visualforce page with apex detail tag and readonly= true and reference the same from the iframe ?
Joey HoJoey Ho

Hi Avi, 

 

Thanks for the idea. I tried this and I realised that the "readonly" attribute of the page component is actually only for stopping users from executing DML operations only but doesn't really stop a user from clicking on links or buttons which make take the to another screen!

 

This defeats the purpose of making my iFrame a 'view only'.... 

 

Anyways, I ended up going with recreating another VF page which duplicates the CASE detail page without the buttons and links such that users can only 'view' the Case record.

 

Only if Salesforce had some kind of attribute that allow 'view only' option which would have saved me the effort!

 

Thanks for your help!

regards,

Joey.

Avidev9Avidev9
Well probably you wont be able to do that. But I guess you can use js/jquery to disable all the anchor tags in the page.
Once you disable them user wont be able to click on the links.
Joey HoJoey Ho

Hi Avi, 

 

thanks about. I thought about that, and that will work too but I think creating a new VF page will be more easier than writing a script for every link/button that is added to the page layout.

 

Thanks again for your time!.

 

Regards,

Joey.

Avidev9Avidev9
I dont think you have to write script for every component. Jquery has selector for selecting all the elements of a particular type. Using few lines of code I guess 5-6 you will be able to disable all the links. Similarly for buttons