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;








2















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










share|improve this question




























    2















    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










    share|improve this question
























      2












      2








      2








      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










      share|improve this question














      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






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 8 hours ago









      RodolfoRodolfo

      538




      538




















          1 Answer
          1






          active

          oldest

          votes


















          5














          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.






          share|improve this answer























          • 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











          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
          );



          );













          draft saved

          draft discarded


















          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









          5














          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.






          share|improve this answer























          • 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















          5














          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.






          share|improve this answer























          • 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













          5












          5








          5







          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.






          share|improve this answer













          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.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered 8 hours ago









          David ReedDavid 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

















          • 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

















          draft saved

          draft discarded
















































          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.




          draft saved


          draft discarded














          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





















































          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







          Popular posts from this blog

          Canceling a color specificationRandomly assigning color to Graphics3D objects?Default color for Filling in Mathematica 9Coloring specific elements of sets with a prime modified order in an array plotHow to pick a color differing significantly from the colors already in a given color list?Detection of the text colorColor numbers based on their valueCan color schemes for use with ColorData include opacity specification?My dynamic color schemes

          Invision Community Contents History See also References External links Navigation menuProprietaryinvisioncommunity.comIPS Community ForumsIPS Community Forumsthis blog entry"License Changes, IP.Board 3.4, and the Future""Interview -- Matt Mecham of Ibforums""CEO Invision Power Board, Matt Mecham Is a Liar, Thief!"IPB License Explanation 1.3, 1.3.1, 2.0, and 2.1ArchivedSecurity Fixes, Updates And Enhancements For IPB 1.3.1Archived"New Demo Accounts - Invision Power Services"the original"New Default Skin"the original"Invision Power Board 3.0.0 and Applications Released"the original"Archived copy"the original"Perpetual licenses being done away with""Release Notes - Invision Power Services""Introducing: IPS Community Suite 4!"Invision Community Release Notes

          François Viète Contents Biography Work and thought Bibliography See also Notes Further reading External links Navigation menup. 21Google Bookspp. 75–77Google BooksDe thou (from University of Saint Andrews)ArchivedGoogle BooksGoogle BooksGoogle BooksGoogle booksGoogle Bookscc-parthenay.frL'histoire universelle (fr)Universal History (en)ArchivedAdsabs.harvard.eduPagesperso-orange.frArchive.orgChikara Sasaki. Descartes' mathematical thought p.259Google BooksGoogle BooksGoogle Bookspp. 152 and onwardGoogle BooksGoogle BooksScribd.comGoogle Books1257-7979Google BooksGoogle BooksGoogle BooksGoogle BooksGoogle BooksGoogle BooksGallica.bnf.frGoogle BooksGoogle Books"François Viète"Francois Viète: Father of Modern Algebraic NotationThe Lawyer and the GamblerAbout TarporleySite de Jean-Paul GuichardL'algèbre nouvelle"About the Harmonicon"cb120511976(data)1188044800000 0001 0913 5903n82164680ola2013766880073431702w6vt1sb70287374827140948071409480