[SalesForce] Lightning shows visualforce pages for new/edit

In Salesforce classic mode, when you create a new record or edit an existing record, the layout of the page does not show any embedded VisualForce pages that would normally show when viewing an existing record. This was all while using the standard Salesforce.com page for the New action.

In the Lightning Experience though, the new and edit layouts now show these embedded VisualForce pages. Is there a way to change this so that it reflects the behavior of classic mode?

Best Answer

You'll want to review the Trailhead Visualforce & Lightning Experience Module. In particular, look at the "Managing Navigation" section. If you want your pages to be compatible with both Classic and Lightning you'll need to create your navigation links using action methods. Don’t create the link by building a string with a static pattern like link = '/' + accountId + '/e'. Instead, use {!URLFOR($Action.Contact.Edit, recordId)}. With JavaScript, use navigateToSObject(recordId).

Most important, Don’t try to set window.location directly (you literally can't access the DOM). This will not work in Lightning because of the "Lightning Wrapper" that serves Visualforce pages inside of an I-frame to a user. This architecture prevents Visualforce pages from accessing the browser window. Visualforce pages are served-up from an entirely different server than Lightning Pages. Even their session Id is different than Lightning pages. See the documentation I referred to for more on this.