LWC: Is it safe to rely on window.location.href to get the page url?Proper/Safe Way to Link to Salesforce ObjectGetting salesforce instance URL from JavaMigrate Aura components with lightning:actionOverride to LWCLWC - How to get label name of buttonsInvoking LWC component from a plain URL - Read URL Parameter inside LWCLWC get url parameters in CommunityLWC: Share @wire between two componentsGet documentforce.com domain URL in LWCLWC lightning file upload validation
Was it illegal to blaspheme God in Antioch in 360.-410.?
Where should I draw the line on follow up questions from previous employer
Ask one verbal question to figure out who is blind and who is mute among three persons
Create a list of snaking numbers under 50,000
What was Captain Marvel supposed to do once she reached her destination?
Is "prohibition against," a double negative?
In Endgame, wouldn't Stark have remembered Hulk busting out of the stairwell?
Can copper pour be used as an alternative to large traces?
Did the Apollo Guidance Computer really use 60% of the world's ICs in 1963?
What's the difference between a variable and a memory location?
Which is the correct version of Mussorgsky's Pictures at an Exhibition?
What are the in-game differences between WoW Classic and the original 2006 Version
Properly unlinking hard links
How to understand payment due date for credit card?
Lob Logical Read and lob read-ahead reads in NCCI
Why does Sauron not permit his followers to use his name?
Eliminate key lookup in execution plan
What are ways to record who took the pictures if a camera is used by multiple people?
Storing milk for long periods of time
Calculate Landau's function
Rapid change in character
Why is there no Disney logo in MCU movies?
My colleague treats me like he's my boss, yet we're on the same level
Is it good practice to speed up and slow down where not written in a song?
LWC: Is it safe to rely on window.location.href to get the page url?
Proper/Safe Way to Link to Salesforce ObjectGetting salesforce instance URL from JavaMigrate Aura components with lightning:actionOverride to LWCLWC - How to get label name of buttonsInvoking LWC component from a plain URL - Read URL Parameter inside LWCLWC get url parameters in CommunityLWC: Share @wire between two componentsGet documentforce.com domain URL in LWCLWC lightning file upload validation
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
Is the SF team planning on deprecating support for the window object?
If so is there a lwc way to get the current url for the loaded page of the component? I couldn't find anything going through the current documentation.
lightning-web-components url
add a comment |
Is the SF team planning on deprecating support for the window object?
If so is there a lwc way to get the current url for the loaded page of the component? I couldn't find anything going through the current documentation.
lightning-web-components url
add a comment |
Is the SF team planning on deprecating support for the window object?
If so is there a lwc way to get the current url for the loaded page of the component? I couldn't find anything going through the current documentation.
lightning-web-components url
Is the SF team planning on deprecating support for the window object?
If so is there a lwc way to get the current url for the loaded page of the component? I couldn't find anything going through the current documentation.
lightning-web-components url
lightning-web-components url
asked 8 hours ago
ArthleteArthlete
1,35212 silver badges24 bronze badges
1,35212 silver badges24 bronze badges
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
You can check Secure Wrappers and Locker API Viewer to get good idea - but it seems to have access and no documentation which says the access would be revoked.
However, the recommended way of getting page reference is through using NavigationMixin & CurrentPageReference.
Sample code JS:
import LightningElement, wire, api, track from 'lwc';
import NavigationMixin, CurrentPageReference from 'lightning/navigation';
export default class Poc extends NavigationMixin(LightningElement)
@wire(CurrentPageReference)
getpageRef(pageRef)
console.log('data => ', JSON.stringify(pageRef));
Output:
When above component was used in Aura component (Name:POC_AURA
) which was loaded directly (isUrlAddressable interface), we get below object as logged:
"type": "standard__component",
"attributes":
"componentName": "c__POC_AURA"
,
"state":
"c__id": "some_id"
When the same LWC component is put in record page of account, we get below logged:
"type": "standard__recordPage",
"attributes":
"objectApiName": "Account",
"recordId": "0010K000028HCgAQAW",
"actionName": "view"
,
"state":
You can refer to different pageReference types that you get.
1
This should be selected as the answer as it has salesforce recommended ways of getting the url.
– Programmatic
8 hours ago
Dude, you are the man! Thanks so much!
– Arthlete
7 hours ago
add a comment |
The best I can find is that when you use window
, locker service returns a secureWindow
object with some differences. You can find the differences here but it doesn't go into detail what those differences are.
You can test functionality in the locker console
1
Wow, thanks for this link, that's awesome! Never seen that before. I'm definitely bookmarking this.
– Arthlete
8 hours ago
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "459"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsalesforce.stackexchange.com%2fquestions%2f275540%2flwc-is-it-safe-to-rely-on-window-location-href-to-get-the-page-url%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
You can check Secure Wrappers and Locker API Viewer to get good idea - but it seems to have access and no documentation which says the access would be revoked.
However, the recommended way of getting page reference is through using NavigationMixin & CurrentPageReference.
Sample code JS:
import LightningElement, wire, api, track from 'lwc';
import NavigationMixin, CurrentPageReference from 'lightning/navigation';
export default class Poc extends NavigationMixin(LightningElement)
@wire(CurrentPageReference)
getpageRef(pageRef)
console.log('data => ', JSON.stringify(pageRef));
Output:
When above component was used in Aura component (Name:POC_AURA
) which was loaded directly (isUrlAddressable interface), we get below object as logged:
"type": "standard__component",
"attributes":
"componentName": "c__POC_AURA"
,
"state":
"c__id": "some_id"
When the same LWC component is put in record page of account, we get below logged:
"type": "standard__recordPage",
"attributes":
"objectApiName": "Account",
"recordId": "0010K000028HCgAQAW",
"actionName": "view"
,
"state":
You can refer to different pageReference types that you get.
1
This should be selected as the answer as it has salesforce recommended ways of getting the url.
– Programmatic
8 hours ago
Dude, you are the man! Thanks so much!
– Arthlete
7 hours ago
add a comment |
You can check Secure Wrappers and Locker API Viewer to get good idea - but it seems to have access and no documentation which says the access would be revoked.
However, the recommended way of getting page reference is through using NavigationMixin & CurrentPageReference.
Sample code JS:
import LightningElement, wire, api, track from 'lwc';
import NavigationMixin, CurrentPageReference from 'lightning/navigation';
export default class Poc extends NavigationMixin(LightningElement)
@wire(CurrentPageReference)
getpageRef(pageRef)
console.log('data => ', JSON.stringify(pageRef));
Output:
When above component was used in Aura component (Name:POC_AURA
) which was loaded directly (isUrlAddressable interface), we get below object as logged:
"type": "standard__component",
"attributes":
"componentName": "c__POC_AURA"
,
"state":
"c__id": "some_id"
When the same LWC component is put in record page of account, we get below logged:
"type": "standard__recordPage",
"attributes":
"objectApiName": "Account",
"recordId": "0010K000028HCgAQAW",
"actionName": "view"
,
"state":
You can refer to different pageReference types that you get.
1
This should be selected as the answer as it has salesforce recommended ways of getting the url.
– Programmatic
8 hours ago
Dude, you are the man! Thanks so much!
– Arthlete
7 hours ago
add a comment |
You can check Secure Wrappers and Locker API Viewer to get good idea - but it seems to have access and no documentation which says the access would be revoked.
However, the recommended way of getting page reference is through using NavigationMixin & CurrentPageReference.
Sample code JS:
import LightningElement, wire, api, track from 'lwc';
import NavigationMixin, CurrentPageReference from 'lightning/navigation';
export default class Poc extends NavigationMixin(LightningElement)
@wire(CurrentPageReference)
getpageRef(pageRef)
console.log('data => ', JSON.stringify(pageRef));
Output:
When above component was used in Aura component (Name:POC_AURA
) which was loaded directly (isUrlAddressable interface), we get below object as logged:
"type": "standard__component",
"attributes":
"componentName": "c__POC_AURA"
,
"state":
"c__id": "some_id"
When the same LWC component is put in record page of account, we get below logged:
"type": "standard__recordPage",
"attributes":
"objectApiName": "Account",
"recordId": "0010K000028HCgAQAW",
"actionName": "view"
,
"state":
You can refer to different pageReference types that you get.
You can check Secure Wrappers and Locker API Viewer to get good idea - but it seems to have access and no documentation which says the access would be revoked.
However, the recommended way of getting page reference is through using NavigationMixin & CurrentPageReference.
Sample code JS:
import LightningElement, wire, api, track from 'lwc';
import NavigationMixin, CurrentPageReference from 'lightning/navigation';
export default class Poc extends NavigationMixin(LightningElement)
@wire(CurrentPageReference)
getpageRef(pageRef)
console.log('data => ', JSON.stringify(pageRef));
Output:
When above component was used in Aura component (Name:POC_AURA
) which was loaded directly (isUrlAddressable interface), we get below object as logged:
"type": "standard__component",
"attributes":
"componentName": "c__POC_AURA"
,
"state":
"c__id": "some_id"
When the same LWC component is put in record page of account, we get below logged:
"type": "standard__recordPage",
"attributes":
"objectApiName": "Account",
"recordId": "0010K000028HCgAQAW",
"actionName": "view"
,
"state":
You can refer to different pageReference types that you get.
edited 8 hours ago
answered 8 hours ago
salesforce-sassalesforce-sas
8,0211 gold badge2 silver badges24 bronze badges
8,0211 gold badge2 silver badges24 bronze badges
1
This should be selected as the answer as it has salesforce recommended ways of getting the url.
– Programmatic
8 hours ago
Dude, you are the man! Thanks so much!
– Arthlete
7 hours ago
add a comment |
1
This should be selected as the answer as it has salesforce recommended ways of getting the url.
– Programmatic
8 hours ago
Dude, you are the man! Thanks so much!
– Arthlete
7 hours ago
1
1
This should be selected as the answer as it has salesforce recommended ways of getting the url.
– Programmatic
8 hours ago
This should be selected as the answer as it has salesforce recommended ways of getting the url.
– Programmatic
8 hours ago
Dude, you are the man! Thanks so much!
– Arthlete
7 hours ago
Dude, you are the man! Thanks so much!
– Arthlete
7 hours ago
add a comment |
The best I can find is that when you use window
, locker service returns a secureWindow
object with some differences. You can find the differences here but it doesn't go into detail what those differences are.
You can test functionality in the locker console
1
Wow, thanks for this link, that's awesome! Never seen that before. I'm definitely bookmarking this.
– Arthlete
8 hours ago
add a comment |
The best I can find is that when you use window
, locker service returns a secureWindow
object with some differences. You can find the differences here but it doesn't go into detail what those differences are.
You can test functionality in the locker console
1
Wow, thanks for this link, that's awesome! Never seen that before. I'm definitely bookmarking this.
– Arthlete
8 hours ago
add a comment |
The best I can find is that when you use window
, locker service returns a secureWindow
object with some differences. You can find the differences here but it doesn't go into detail what those differences are.
You can test functionality in the locker console
The best I can find is that when you use window
, locker service returns a secureWindow
object with some differences. You can find the differences here but it doesn't go into detail what those differences are.
You can test functionality in the locker console
answered 8 hours ago
ProgrammaticProgrammatic
1,3221 gold badge22 silver badges49 bronze badges
1,3221 gold badge22 silver badges49 bronze badges
1
Wow, thanks for this link, that's awesome! Never seen that before. I'm definitely bookmarking this.
– Arthlete
8 hours ago
add a comment |
1
Wow, thanks for this link, that's awesome! Never seen that before. I'm definitely bookmarking this.
– Arthlete
8 hours ago
1
1
Wow, thanks for this link, that's awesome! Never seen that before. I'm definitely bookmarking this.
– Arthlete
8 hours ago
Wow, thanks for this link, that's awesome! Never seen that before. I'm definitely bookmarking this.
– Arthlete
8 hours ago
add a comment |
Thanks for contributing an answer to Salesforce Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsalesforce.stackexchange.com%2fquestions%2f275540%2flwc-is-it-safe-to-rely-on-window-location-href-to-get-the-page-url%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown