5

When popup window is closed I received a response from server which i need to pass in my callGetToken function. Everything is working fine in Firefox and IE but the function is not called in Chrome, can anyone tell me what is causing this? My Chrome version is 30.0.1599.101 m

function authentication{
var newwindow=window.showModalDialog(url,'',"dialogWidth:800px;dialogHeight:600px;dialogLeft:200px");
callgetToken(oid);
}
function callgetToken(oid){
alert('Hi');
getToken(oid);
}
<apex:actionFunction name="getToken" action="{!callAccessToken}" rerender="theForm" status="status">
  <apex:param name="org_id" value="" assignTo="{!org_id}" />
 </apex:actionFunction>
  • 1
    Welcome to SFSE. Flagging your own question is NOT the way to attract attention. Flagging is used to alert of serious issues with a certain post, and not to get the community attention. – Saariko Nov 6 '13 at 10:58
  • @Aisha What javascript code you have written in showModalDialog page? – Ashwani Nov 6 '13 at 13:44
  • 1
    @regal i write the below code on showModalDialog page <script> var code = '{!HTMLENCODE(response)}'; if(code!=""){ this.close(); } </script> – Tepsi Nov 7 '13 at 5:33
  • @regal i call a remote site page(popup) on click of a button and when the window is close callgetToken is not running in chrome but the same code is working in firefox plz help i don't understand what is the possible solution – Tepsi Nov 7 '13 at 8:23
  • 2
    @regal thank you for ur help. I got the solution now after a long time. – Tepsi Nov 8 '13 at 10:58
3

Thank you all for your solutions. Yes I have Security issue due to domain portability and i got the solution by The document.domain exception section in given link may be it help some more users...

http://javascript.info/tutorial/same-origin-security-policy

  • 1
    Other sections are also good and can be use to resolve the security issue. – Tepsi Nov 8 '13 at 10:56
  • 1
    other link given above in other answers is also very good. – Tepsi Nov 8 '13 at 11:00
2

This is alternative solution :

I got this problem. But I found the alternative solution.

The alternative solution is below:

Step : 1 --> Create a hidden input element on parent page. eg:-`

<input type="hidden" id="token" />`

Step : 2 --> Access this element in your child/Dialog window and feed the value in it before the close event.

window.opener.document.getElementById('token').value = 'XXXXX';

Step 3 :---> In you Parent window code look like:

function authentication{
  var newwindow=window.showModalDialog(url,'',"dialogWidth:800px;dialogHeight:600px;dialogLeft:200px");
var oid = document.getElementById('token').value;
  callgetToken(oid);
}

function callgetToken(oid){
  alert('Hi');
  getToken(oid);
}

In html 
<input type="hidden" id="token" />
  • we already have the value of oid which is organization id in my case but when window is close next line is not executed in Chrome – Tepsi Nov 6 '13 at 9:07
  • this problem comes when page is not getting same domain or port. – D-Horse Nov 6 '13 at 11:28
  • what do you mean by same domain or port??? – Tepsi Nov 7 '13 at 5:32
  • Thank you for ur help. I got the solution after a long time. – Tepsi Nov 8 '13 at 10:55
1

Did some change in your code:

Parent side (no changes on child window):

<apex:form >
<apex:actionFunction name="getToken" action="{!help}" rerender="theForm" status="status">
 </apex:actionFunction>
</apex:form>
<script>
            function authentication() {
                var oid="abc"; // test only
                window.showModalDialog('https://c.na15.visual.force.com/apex/investmentvisualization','',"dialogWidth:800px;dialogHeight:600px;dialogLeft:200px");
                callgetToken(oid);
            }
            function callgetToken(oid) {
                alert('Hi');
                getToken(oid);
           }
</script>
  • Javascript authentication function has type mistake, it should be authentication().

  • Above code works properly and the possible error you can get is "blocked frame origin...", something like this. This happens because of parent has different url then child window url. Properly explained here: iframe: Protocols, domains, and ports must match error

  • In my case parent origin page is: https://c.na15.visual.force.com/apex/investmentvisualization and model dialog has the same. However it can be https://c.na15.visual.force.com/apex/someOthrePage.

  • i call a remote site page(popup) on click of a button and when the window is close callgetToken is not running in chrome but the same code is working in firefox plz help i don't understand what is the possible solution – Tepsi Nov 7 '13 at 9:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.