APIs & Integrations

milesbro
Member

Extension parent refresh

Is there a way of refreshing the parent page from a crm extension iframe? This is needed when the underlying record has been updated (via API's) but still showing as was until the user refreshes the record manually.  In my case the card is a deal card of which a called "iframe" updates the deal value but is not visible to the user until they refresh/reaccess the record?

0 Upvotes
7 Replies 7
geraldgwarp
Member

Extension parent refresh

The History interface allows manipulation of the browser session history , that is the pages visited in the tab or frame that the current page is loaded in.

 

There are multiple ways to Refresh/Reload a page with jQuery/JavaScript, some are:

 

location.href = location.href
location.replace(location.pathname)
window.location = window.location
window.self.window.self.window.window.location = window.location

 

0 Upvotes
WendyGoh
HubSpot Employee
HubSpot Employee

Extension parent refresh

Hey @milesbro,

 

For this, I believe you can implement the location.reload() method to reload the current URL - essentially it's like a refresh button. 

0 Upvotes
milesbro
Member

Extension parent refresh

Have tried multiple attempts of varying combinations of .reload() including .parent.location and top.location etc. All of which  seem to be blocked because of cross-domain restrictions ie iframes of a different domain can not "take control" of the parent page for the likes of url and/or reload. 

 

Apart from an on page message requesting the user to manually refresh is there any other possibly solutions or work-arounds?

 

0 Upvotes
Derek_Gervais
HubSpot Alumni
HubSpot Alumni

Extension parent refresh

Hey all,

 

I just double checked with the team, and refreshing the parent page from a CRM Extension iframe isn't supported. The only actions from within the iframe that HubSpot supports is the window.postMessage method used to close the modal window.

milesbro
Member

Extension parent refresh

Thanks for checking. 

 

I wil have to display a message to the user to say "please refresh". Not ideal.  

 

Can the feature be added in a future release please? prehaps an option for the window.postMessage?

 

 

 

0 Upvotes
Derek_Gervais
HubSpot Alumni
HubSpot Alumni

Extension parent refresh

Hey @milesbro ,

 

I didn't go into much detail previously, but it's actually not a limitation that HubSpot enforces; it's actually due to the way the Same Origin Policy works in the browser. Because your iframe and the parent window are always going to be loaded from different places, the browser will prevent your code from refreshing the parent. That said, I'm happy to pass this feedback along to my team in case there's the potential for a workaround. I'd also recommend creating an idea in the HubSpot Ideas Forum as well, if you haven't yet.

 

This Stackoverflow article has some more detail; specificially, check out the comment under the top answer:

https://stackoverflow.com/questions/5351342/reload-parent-window-from-within-an-iframe

milesbro
Member

Extension parent refresh