I'm trying to have some code run when the Billing Address field (or sub-fields) of an Account is changed. This code will clean up the address, and then I want it to replace the contents of the Billing Address field with the cleaned up address without saving, so the user can preview the cleaned-up address.

Right now I'm trying to do this by editing the Account page layout to include an embedded VF page that contains javascript code. I found that the div that actually contains the address has id="acc17_ileinner".

I tried:

$(document).ready(function() {

to see if I could access that div, but the alert said "undefined".

Do embedded VF pages use a separate document node? How can I access the standard field from a VF page embedded in the page layout of a standard object like Account?

3 Answers 3


Yes inline VisualForce Pages execute in an iframe from a different origin and your approach will not work for security reasons. In addition, such VisualForce Pages do not render on the edit page, so this will not work for that scenario even if the page were not in an iframe.

If you want to modify addresses after a user inputs them and must do so on the front end, you could remove the fields involved from the Page Layout and have an embedded page that contains the inputFields you want and has its own save action. This page could contain your cleanup logic. It is somewhat confusing to have multiple save buttons on one page but this approach would give you what you want.


Unfortunately it cannot be done with Javascript. Salesforce Standardpage and inline Visualforce page (Iframe) served from different address and you will get error of Same origin security.

You cannot use Standard workflow rule also because it doesnt support address type of field in field update, You can check these few considerations for field update.

Your problem can be well solved with Trigger by comparing old and new value of address.

  • You could, however, examine BillingAddress. Also your link does not support your claim as far as I can tell. Please include a supporting quote.
    – Adrian Larson
    May 12, 2015 at 20:52
  • Yeah, I have updated answer. In my dev Org, quick checked and Account address field doesn't appear to be updated. May 12, 2015 at 20:55
  • A trigger won't work for me because I can only set up a trigger to fire after the user clicks Save. I need to run my cleanup code as soon as they change the field so they can see the clean address before saving.
    – Neo
    May 12, 2015 at 21:37
  • In that case, i think you would need to override standard edit page with visualforce. May 12, 2015 at 22:04

Embedded inline vf pages will be inside another iframe. So direct selectors will not work. You have to select as below,


If you are considering overriding with a visualforce page, then you can use direct selectors

  • I didn't think you could listen on the parent window...have you successfully implemented this?
    – Adrian Larson
    May 12, 2015 at 20:48
  • It works in generic iframe context. Should work in visualforce page also. Please give a try.
    – Victor
    May 12, 2015 at 20:53
  • When I try window.parent.$(elementid).html(), I get a security error because the javascript is served from a different domain.
    – Neo
    May 12, 2015 at 20:59
  • oh forgot about that. You might have to use a single VF page I think. Inline pages will be served from visualforce.com domain.
    – Victor
    May 12, 2015 at 21:03
  • How can I override the standard Account page with a VF page that looks and works identically to the original?
    – Neo
    May 12, 2015 at 21:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .