+ Start a Discussion
rjday1.3964593263009905E12rjday1.3964593263009905E12 

Display dynamically updated URL for iframe on Visualforce page

Hi! For customer support handling, I have created a visualforce page with an iframe that loads our external help site. This way I am able to navigate our help articles without leaving salesforce.

However, when I find an applicable solution, I would like to copy that URL to paste in an email to the customer.

I tried putting {!$CurrentPage.URL} above my iframe but that just displays the URL to my Visualforce tab.

How do I display my iFrame url? Note that this URL will need to dynamically update as I navigate to different help articles.

Thanks!
Best Answer chosen by rjday1.3964593263009905E12
bob_buzzardbob_buzzard
I don't think you'll be able to get at the URL for the frame directly from the Visualforce page, as they are served from seperate domains.  The browser same origin policy only allows pages from the same domain access to each other's information.  

You may be able to do this using the HTML5 postMessage functionality, but your external help site would need to post a message to your VF page each time the user navigated to a different page, so you'd need to make some changes to both sides. There's more information about message posting at : http://davidwalsh.name/window-postmessage

All Answers

bob_buzzardbob_buzzard
I don't think you'll be able to get at the URL for the frame directly from the Visualforce page, as they are served from seperate domains.  The browser same origin policy only allows pages from the same domain access to each other's information.  

You may be able to do this using the HTML5 postMessage functionality, but your external help site would need to post a message to your VF page each time the user navigated to a different page, so you'd need to make some changes to both sides. There's more information about message posting at : http://davidwalsh.name/window-postmessage
This was selected as the best answer
rjday1.3964593263009905E12rjday1.3964593263009905E12
That clears up a lot. Thanks!