+ Start a Discussion
kzmpkzmp 

Javascript in Visual Force page does not work properly in Console due to cross-domain issues

Hi,

We have an application which monitors whether the user has edited something in the Leads detail page and pops up an HTML window with some data.

Because in SalesForce it is not possible to override the save button we have hacked that shortcoming by creating a Visual Force page which has a bit of JavaScript which can popup our HTML window based on whether our controller says that the Lead in question has been modified. So basically the user edits a lead hits save and we popup our window.

 

Now in our HTML window which pops up the user may change a value of the Lead he has just edited. To reflect that in the view we refresh the page with JavaScript  like this:

window.parent.location = "{!the parent url which the controller knows}"

 

Now the problem is when the detail view is seen in the salesforce console. In the console window.parent in our visualforce page gives us the iframe but because of cross-domain security we are not able to set the location property. We can do so on the parent like window.parent.parent.location = "{!the parent url which the controller knows}" but this is not what we want as this refreshes the whole console window and is lossing state.

 

We tried something differently I though if we put a button which does a post back on our Visual Force page and we hide the button but click it with JavaScript it will do a postback and it will refresh the iframe. That did not work. It only refreshed our Visual Force page.

Any help on how can we achieve our goals will be appreciated.

 

To reiterate the problems we are trying to solve:

   1. How can we popup something after the user has edited a record and then refresh the current page. => we partially solved that by creating a Visual Force page which does it and refreshes the page. This brought us to another problem in Console:

      1.1. How can we refresh just the iframe from a Visual Force page embedded in the layout of the Leads layout?

 

Any help on how to resolve either 1 or 1.1 will be appreciated.

 

Thanks,

Kos

RamboRambo

Try using Yahoo User Interface(YUI) to use the popup which is simple enough just by passing your id to the perdefined methods.

 

Inorder to refresh the parent window on closure of the popup window try using this statement in the javascript u used for closing the popup

 

 window.parent.location.replace('/{!$CurrentPage.parameters.id}');

 

else if u want to refresh just the inline vf u have used tyr using this

 

window.location.reload(true);

(or)

window.opener.history.go(0);

 

 

kzmpkzmp

Hi Rambo,

Thanks you for your reply.

I am not familiary with Yahoo User interface but could you quickly give any advantages over JQuery litebox or any other overlay?

I mean I am familiar with JQuery litebox which does the same job it pups up in an overlay I would consider yahoo user interface if for example it is already loaded by SalesForce and no additional library has to be registered as it is the case with JQuery.

 

On the second part to clarify that my problem is that if I refresh the parent page I loose the state of all it's children iframes.

Ideally I do want to refresh one of the iframes there. The problem with that is that I am trying to refresh it with javascript from my custom Visual Force page which comes from a different domain.

The heierachy is:

form  

 -----iframe    <- I want to refresh this iframe from the form below

------------form       <- Comes from a different doamin. This is my custom VF page in which I have put some javascript

What happens is I can refresh the tompost parent but I cannot refresh my immediate parent - the iframe.

 

Thanks,

kzmp

 

Mats ErikssonMats Eriksson

kzmp, any solution to this issue?

 

/Mats