Access to all elements on the pageHow to use jQuery (or any JS lib) in initial post rendering of Lightning ComponentsAura StaticResource Javascript helper classesLightning Component - Locker Service: Onclick button, div no longer workingWhy can't I have an onclick on a button element inside a form element?get values in lightning:input with $A.createComponentsAttach a Lightning Component to the DOM dynamicallyHide Flow buttons in salesforce'Script Error' in my Lightning Component?Lightning component is hang for first timeCreating hyperlinks in lightning community record tempaltes
How to detach yourself from a character you're going to kill?
Is there a rule that prohibits us from using 2 possessives in a row?
Benefits of employing devices that support vlan trunking
How to decline physical affection from a child whose parents are pressuring them?
Hygienic footwear for prehensile feet?
Is it a problem that pull requests are approved without any comments
I made a mistake ordering ground coffee - will Expresso ground coffee work for a French Press?
What people are called boars ("кабан") and why?
Should we freeze the number of people coming in to the study for Kaplan-Meier test
Is there any Biblical Basis for 400 years of silence between Old and New Testament?
Applicants clearly not having the skills they advertise
Working in the USA for living expenses only; allowed on VWP?
Do I add my ability modifier to the damage of the bonus-action attack granted by the Crossbow Expert feat?
Is American Express widely accepted in France?
Can The Malloreon be read without first reading The Belgariad?
What's the most polite way to tell a manager "shut up and let me work"?
Why was it possible to cause an Apple //e to shut down with SHIFT and paddle button 2?
If a problem only occurs randomly once in every N times on average, how many tests do I have to perform to be certain that it's now fixed?
How do you translate “is all” used at the end of a sentence?
How to provide realism without making readers think grimdark
What is the best option to connect old computer to modern TV
Have powerful mythological heroes ever run away or been deeply afraid?
Do adult Russians normally hand-write Cyrillic as cursive or as block letters?
PhD student with mental health issues and bad performance
Access to all elements on the page
How to use jQuery (or any JS lib) in initial post rendering of Lightning ComponentsAura StaticResource Javascript helper classesLightning Component - Locker Service: Onclick button, div no longer workingWhy can't I have an onclick on a button element inside a form element?get values in lightning:input with $A.createComponentsAttach a Lightning Component to the DOM dynamicallyHide Flow buttons in salesforce'Script Error' in my Lightning Component?Lightning component is hang for first timeCreating hyperlinks in lightning community record tempaltes
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I want to access to DOM in Page for edit a standard style of lightning
If I execute this script in the Chrome console, I can edit all buttons in the page:
var doc = document.getElementsByClassName("slds-button--brand");
for(var i=0; i<doc.length; i++)
doc[i].style.backgroundColor = "pink";
Now, I execute the function in lightning component, in a button:
cmp
<div>
<button class="slds-button slds-button_brand slds-m-top_small" label="Testtt11" onclick="!c.test">
<span class="label bBody" dir="ltr" data-aura-rendered-by="2255:0">
Test
</span>
</button>
</div>
controller
test : function(component, event, helper)
var doc = document.getElementsByClassName("slds-button--brand");
for(var i=0; i<doc.length; i++)
doc[i].style.backgroundColor = "pink";
,
But in my lightning component only modify my buton, no all butons in the page
How can access to all elements on the page?
Thanks
lightning-aura-components
add a comment |
I want to access to DOM in Page for edit a standard style of lightning
If I execute this script in the Chrome console, I can edit all buttons in the page:
var doc = document.getElementsByClassName("slds-button--brand");
for(var i=0; i<doc.length; i++)
doc[i].style.backgroundColor = "pink";
Now, I execute the function in lightning component, in a button:
cmp
<div>
<button class="slds-button slds-button_brand slds-m-top_small" label="Testtt11" onclick="!c.test">
<span class="label bBody" dir="ltr" data-aura-rendered-by="2255:0">
Test
</span>
</button>
</div>
controller
test : function(component, event, helper)
var doc = document.getElementsByClassName("slds-button--brand");
for(var i=0; i<doc.length; i++)
doc[i].style.backgroundColor = "pink";
,
But in my lightning component only modify my buton, no all butons in the page
How can access to all elements on the page?
Thanks
lightning-aura-components
add a comment |
I want to access to DOM in Page for edit a standard style of lightning
If I execute this script in the Chrome console, I can edit all buttons in the page:
var doc = document.getElementsByClassName("slds-button--brand");
for(var i=0; i<doc.length; i++)
doc[i].style.backgroundColor = "pink";
Now, I execute the function in lightning component, in a button:
cmp
<div>
<button class="slds-button slds-button_brand slds-m-top_small" label="Testtt11" onclick="!c.test">
<span class="label bBody" dir="ltr" data-aura-rendered-by="2255:0">
Test
</span>
</button>
</div>
controller
test : function(component, event, helper)
var doc = document.getElementsByClassName("slds-button--brand");
for(var i=0; i<doc.length; i++)
doc[i].style.backgroundColor = "pink";
,
But in my lightning component only modify my buton, no all butons in the page
How can access to all elements on the page?
Thanks
lightning-aura-components
I want to access to DOM in Page for edit a standard style of lightning
If I execute this script in the Chrome console, I can edit all buttons in the page:
var doc = document.getElementsByClassName("slds-button--brand");
for(var i=0; i<doc.length; i++)
doc[i].style.backgroundColor = "pink";
Now, I execute the function in lightning component, in a button:
cmp
<div>
<button class="slds-button slds-button_brand slds-m-top_small" label="Testtt11" onclick="!c.test">
<span class="label bBody" dir="ltr" data-aura-rendered-by="2255:0">
Test
</span>
</button>
</div>
controller
test : function(component, event, helper)
var doc = document.getElementsByClassName("slds-button--brand");
for(var i=0; i<doc.length; i++)
doc[i].style.backgroundColor = "pink";
,
But in my lightning component only modify my buton, no all butons in the page
How can access to all elements on the page?
Thanks
lightning-aura-components
lightning-aura-components
asked 8 hours ago
RodolfoRodolfo
538
538
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
You can't. Locker Service is designed specifically to prevent your JavaScript in Lightning Components from reaching into DOM and resources managed by components in other namespaces, including the system namespace.
Here's a quick summary from LockerService and Lightning Container Component: Securely Using Third-Party Libraries in Lightning Components
:
LockerService is the primary and preferred isolation mechanism for the Lightning Component Framework. LockerService wraps standard objects like window, document, and element inside a secure version of these objects (SecureWindow, SecureDocument and SecureElement) as a way to control access to APIs and regions of the DOM. When components are loaded, they are provided with the secure wrappers (secureWindow and secureDocument) in lieu of the standard objects (window and document). When a component invokes a method on the document or window object, the secure wrapper can apply appropriate security restrictions. For example, access to the DOM of another component will be:
- Granted if the other component is in the same namespace.
- Denied if the other component is in a different namespace.
You won't be able to affect system components or their DOM elements from your Lightning JavaScript, by design.
Hi David, and with VisualForce? Put a visual into lightning...
– Rodolfo
8 hours ago
1
@Rodolfo Visualforce is run in a frame in lightning and I believe it is delivered from a different domain which triggers security measures within the browser itself. Regardless, the answer really is "you can't, and even if you could, you shouldn't"
– gNerb
8 hours ago
1
What @gNerb said. See Trailhead module on the Visualforce container in Lightning. Put simply, there is no supported way to do what you are trying to do. The best route is probably a browser extension.
– David Reed♦
8 hours ago
Ok, thank you very much
– Rodolfo
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%2f264242%2faccess-to-all-elements-on-the-page%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You can't. Locker Service is designed specifically to prevent your JavaScript in Lightning Components from reaching into DOM and resources managed by components in other namespaces, including the system namespace.
Here's a quick summary from LockerService and Lightning Container Component: Securely Using Third-Party Libraries in Lightning Components
:
LockerService is the primary and preferred isolation mechanism for the Lightning Component Framework. LockerService wraps standard objects like window, document, and element inside a secure version of these objects (SecureWindow, SecureDocument and SecureElement) as a way to control access to APIs and regions of the DOM. When components are loaded, they are provided with the secure wrappers (secureWindow and secureDocument) in lieu of the standard objects (window and document). When a component invokes a method on the document or window object, the secure wrapper can apply appropriate security restrictions. For example, access to the DOM of another component will be:
- Granted if the other component is in the same namespace.
- Denied if the other component is in a different namespace.
You won't be able to affect system components or their DOM elements from your Lightning JavaScript, by design.
Hi David, and with VisualForce? Put a visual into lightning...
– Rodolfo
8 hours ago
1
@Rodolfo Visualforce is run in a frame in lightning and I believe it is delivered from a different domain which triggers security measures within the browser itself. Regardless, the answer really is "you can't, and even if you could, you shouldn't"
– gNerb
8 hours ago
1
What @gNerb said. See Trailhead module on the Visualforce container in Lightning. Put simply, there is no supported way to do what you are trying to do. The best route is probably a browser extension.
– David Reed♦
8 hours ago
Ok, thank you very much
– Rodolfo
8 hours ago
add a comment |
You can't. Locker Service is designed specifically to prevent your JavaScript in Lightning Components from reaching into DOM and resources managed by components in other namespaces, including the system namespace.
Here's a quick summary from LockerService and Lightning Container Component: Securely Using Third-Party Libraries in Lightning Components
:
LockerService is the primary and preferred isolation mechanism for the Lightning Component Framework. LockerService wraps standard objects like window, document, and element inside a secure version of these objects (SecureWindow, SecureDocument and SecureElement) as a way to control access to APIs and regions of the DOM. When components are loaded, they are provided with the secure wrappers (secureWindow and secureDocument) in lieu of the standard objects (window and document). When a component invokes a method on the document or window object, the secure wrapper can apply appropriate security restrictions. For example, access to the DOM of another component will be:
- Granted if the other component is in the same namespace.
- Denied if the other component is in a different namespace.
You won't be able to affect system components or their DOM elements from your Lightning JavaScript, by design.
Hi David, and with VisualForce? Put a visual into lightning...
– Rodolfo
8 hours ago
1
@Rodolfo Visualforce is run in a frame in lightning and I believe it is delivered from a different domain which triggers security measures within the browser itself. Regardless, the answer really is "you can't, and even if you could, you shouldn't"
– gNerb
8 hours ago
1
What @gNerb said. See Trailhead module on the Visualforce container in Lightning. Put simply, there is no supported way to do what you are trying to do. The best route is probably a browser extension.
– David Reed♦
8 hours ago
Ok, thank you very much
– Rodolfo
8 hours ago
add a comment |
You can't. Locker Service is designed specifically to prevent your JavaScript in Lightning Components from reaching into DOM and resources managed by components in other namespaces, including the system namespace.
Here's a quick summary from LockerService and Lightning Container Component: Securely Using Third-Party Libraries in Lightning Components
:
LockerService is the primary and preferred isolation mechanism for the Lightning Component Framework. LockerService wraps standard objects like window, document, and element inside a secure version of these objects (SecureWindow, SecureDocument and SecureElement) as a way to control access to APIs and regions of the DOM. When components are loaded, they are provided with the secure wrappers (secureWindow and secureDocument) in lieu of the standard objects (window and document). When a component invokes a method on the document or window object, the secure wrapper can apply appropriate security restrictions. For example, access to the DOM of another component will be:
- Granted if the other component is in the same namespace.
- Denied if the other component is in a different namespace.
You won't be able to affect system components or their DOM elements from your Lightning JavaScript, by design.
You can't. Locker Service is designed specifically to prevent your JavaScript in Lightning Components from reaching into DOM and resources managed by components in other namespaces, including the system namespace.
Here's a quick summary from LockerService and Lightning Container Component: Securely Using Third-Party Libraries in Lightning Components
:
LockerService is the primary and preferred isolation mechanism for the Lightning Component Framework. LockerService wraps standard objects like window, document, and element inside a secure version of these objects (SecureWindow, SecureDocument and SecureElement) as a way to control access to APIs and regions of the DOM. When components are loaded, they are provided with the secure wrappers (secureWindow and secureDocument) in lieu of the standard objects (window and document). When a component invokes a method on the document or window object, the secure wrapper can apply appropriate security restrictions. For example, access to the DOM of another component will be:
- Granted if the other component is in the same namespace.
- Denied if the other component is in a different namespace.
You won't be able to affect system components or their DOM elements from your Lightning JavaScript, by design.
answered 8 hours ago
David Reed♦David Reed
43.4k82564
43.4k82564
Hi David, and with VisualForce? Put a visual into lightning...
– Rodolfo
8 hours ago
1
@Rodolfo Visualforce is run in a frame in lightning and I believe it is delivered from a different domain which triggers security measures within the browser itself. Regardless, the answer really is "you can't, and even if you could, you shouldn't"
– gNerb
8 hours ago
1
What @gNerb said. See Trailhead module on the Visualforce container in Lightning. Put simply, there is no supported way to do what you are trying to do. The best route is probably a browser extension.
– David Reed♦
8 hours ago
Ok, thank you very much
– Rodolfo
8 hours ago
add a comment |
Hi David, and with VisualForce? Put a visual into lightning...
– Rodolfo
8 hours ago
1
@Rodolfo Visualforce is run in a frame in lightning and I believe it is delivered from a different domain which triggers security measures within the browser itself. Regardless, the answer really is "you can't, and even if you could, you shouldn't"
– gNerb
8 hours ago
1
What @gNerb said. See Trailhead module on the Visualforce container in Lightning. Put simply, there is no supported way to do what you are trying to do. The best route is probably a browser extension.
– David Reed♦
8 hours ago
Ok, thank you very much
– Rodolfo
8 hours ago
Hi David, and with VisualForce? Put a visual into lightning...
– Rodolfo
8 hours ago
Hi David, and with VisualForce? Put a visual into lightning...
– Rodolfo
8 hours ago
1
1
@Rodolfo Visualforce is run in a frame in lightning and I believe it is delivered from a different domain which triggers security measures within the browser itself. Regardless, the answer really is "you can't, and even if you could, you shouldn't"
– gNerb
8 hours ago
@Rodolfo Visualforce is run in a frame in lightning and I believe it is delivered from a different domain which triggers security measures within the browser itself. Regardless, the answer really is "you can't, and even if you could, you shouldn't"
– gNerb
8 hours ago
1
1
What @gNerb said. See Trailhead module on the Visualforce container in Lightning. Put simply, there is no supported way to do what you are trying to do. The best route is probably a browser extension.
– David Reed♦
8 hours ago
What @gNerb said. See Trailhead module on the Visualforce container in Lightning. Put simply, there is no supported way to do what you are trying to do. The best route is probably a browser extension.
– David Reed♦
8 hours ago
Ok, thank you very much
– Rodolfo
8 hours ago
Ok, thank you very much
– Rodolfo
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%2f264242%2faccess-to-all-elements-on-the-page%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