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
FastSnailFastSnail 

Pop-Up blocker from Safari on window.open with ActionSupport.onComplete (iPad/iPhone)

Hello everyone,
I get the ‘This site is attempting to open a pop-up window – Block - Allow’ on Safari only, in the below context. Can anyone help me to get rid of it?  Thanks in advance.
A VF page (Item) has an ‘Show’ icon that, when clicked,  is opening a NEW VF page (Gallery) to display the pictures of the item, in a separate window/tab.
Before calling Gallery, Item inserts an encrypted cookie (picRecId) build with an Apex method (encryptCookie), that is decrypted by Gallery constructor with another Apex method (decrytCookie).

It looks like this:
Item VF page:
‘oncomplete’ makes sure that when Gallery opens, the picRecId cookie has been inserted. This works fine on all platform BUT I get the pop-up blocker on Safari (iPad/iPhone).
<img src="https://.../showpictureicon" />
<apex:actionSupport event="onclick" action="{!encryptCookie}"
oncomplete="window.open('gallery', 'gallery')" reRender="itemAopNul" >
<apex:param name="picRecId" value="{!ref.id}" />
</apex:actionSupport>

The turnaround I am using for now, which I feel is not robust enough:
Below works with ‘onsubmit’. The pop-up blocker does not appear, but there is a risk that the picRecId cookie is not yet inserted when ‘Gallery’ loads = no good.
Furthermore, trials and error shows me that if the timer is set to 3000, rather than 1000, the pop-up blocker does appear, fur unclear to me reason. If set to 100, the cookie is not inserted on time.
<img src="https://.../showpictureicon" />
<apex:actionSupport event="onclick" action="{!encryptCookie}"
onsubmit="setTimeout(function(){window.open('gallery', 'gallery');}, 1000);" reRender="itemAopNul" >
<apex:param name="picRecId" value="{!ref.id}" />
</apex:actionSupport>

Is there any solution that 1)Makes sure that the picRecId cookie is inserted BEFORE Gallery loads and 2)The pop-up block does not appear?
Thanks again in advance for your help.
All the best,
Jerome
AbhishekAbhishek (Salesforce Developers) 
Hi Jerome,

Can you go through the below blogs which might answer your query,

https://stackoverflow.com/questions/9514698/bypass-popup-blocker-on-window-open-when-jquery-event-preventdefault-is-set

http://lexisnexis.custhelp.com/app/answers/answer_view/a_id/1100397/~/configure-pop-up-blocker-exceptions-in-safari-12-and-above

I hope you find the above information helpful. If it does, please mark as Best Answer to help others too.

Thanks.
FastSnailFastSnail
Hello Abhishek,
Thanks for the quick reply.  I am looking into the first link, trying how to implement it in SFDC. Would you have any examples handy?
Also why does the pop-up blocker appear only on Safari iPad/iPhone and none of the other devices/browsers. Even Safari on Mac does not have this issue? Thanks in advance,
Jerome