getPageInfo() for Salesforce Classic

Usage 

Returns information about the current page.

Syntax 

1sforce.interaction.getPageInfo(callback:function);

Arguments 

NameTypeDescription
callbackfunctionJavaScript method executed when the API method call is completed.

Sample Code–JavaScript 

1<html>
2<head>
3   <script type="text/javascript" src="http://domain:port/support/api/25.0/interaction.js"></script>
4   <script type="text/javascript">
5       var callback = function (response) {
6           if (response.result) {
7                  alert(response.result);
8            } else {
9                   alert(response.error);
10           }
11        };
12       function getPageInfo() {
13                //Invokes API method
14                sforce.interaction.getPageInfo(callback);
15        }
16</script>
17</head>
18<body>
19       <button onclick="getPageInfo();">getPageInfo</button>
20</body>
21</html>

Response 

NameTypeDescription
resultstringReturns the URL of the current page as a JSON string, including any applicable object ID, object name, object type, and for API version 33.0 or later, the object tab name. For API version 31.0 and later, invoking this method on a PersonAccount object also returns accountId or contactId, and personAccount (true if the object is a PersonAccount, false otherwise).
errorstringIf the API call was successful, this variable is undefined. If the API call failed, this variable returns an error message.

Example result:

1{"url":"https://MYDOMAINNAME.my.salesforce.com/001x0000003DGQR",
2"objectId":"001x0000003DGQR","objectName":"Acme",
3"object":"Account","displayName":"Company"}

Example result for a PersonAccount object (API version 31.0 and later):

1{"url":"https://MYDOMAINNAME.my.salesforce.com/001x0000003DGQR",
2"objectId":"001x0000003DGQR","objectName":"Acme Person Account",
3"object":"Account", "contactId":"003D000000QOMqg", "personAccount":true}