function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

How to find the page's URL from inside an embedded VF page using Javascript?

I've created a visualforce page using the Account standard controller inside the service console.


Under normal circumstances and normal embedded pages, the code below seems to work just fine.


currentPage = document.location.href;
if (window !=
    currentPage = document.referrer;

 When window !=, then we're an iframe and document.referrer gives me the answer I want.


But, when I'm inside a service console layout, none of the attempts below seem to produce anything useable.



 And certainly, none of them fit inside a visualforce URL datatype field limited to 255 characters, but that's another complaint.


Does anyone have an idea how I'm supposed to get a usable URL from inside an iframe on a service console page layout?

Best Answer chosen by Admin (Salesforce Developers) 

It turns out "document.referrer" isn't bad, but it is more than 255 characters--which means it can't be stored in a URL field.


So now I'm trying to find out how to change my url__c field from a URL type to a textarea of at least 2048 bytes.