IE11 selectionchange event activeTarget changes activeTarget when logged









up vote
0
down vote

favorite












Im trying to get the activeTarget of the selectionChange event in IE11 when using the inbuilt search to step through the matches. In firefox and Edge the follow code will log the the element closest to where the element is. So the input "test test" would return the link element.



In IE11 the log of the whole event will contain the anchor element in the target -> activeElement but when you try to log it it will log event.target.activeElement the body element be logged instead.



Does anyone know what might be going on and/or how to work around this issue? Helps much appreciated.



html:



 <html>
<body>
<div class="block display-option-100 expandedblock">

<div class="expand-block block__generic-body" data-expandblock>

<div class="block__row">

<div tabindex="0" class="expand-block__clickable-row" role="tab" aria-controls="114428">

<h2 class="block__heading expand-block__heading ">H55445DEerpfsdfdfs</h2>
<span class="expand-block__statuslabel" data-nojs-hidden>
<span class="statuslabel__open"></span>
<span class="statuslabel__close"></span>
</span>

</div>

<div id="114428" class="expand-block__content" data-expandblockcontent role="tabpanel" aria-expanded="false">

<p><a title="Här testar vi" href="/testi/">Testitesti Rapport</a></p>
<p>&nbsp;</p>
<p><a href="test">herpderp test test</a><br><a href="herp derp">test test jfdsnjdnjf <br></a><a href="fdgfdghfgfdfdg">test tastdsoin tstest</a><br><a href="gfdgfdgfdgfd">yat yat yat yta ggdsggd</a></p>
</div>

</div>
</div>
</div>
</body>
</html>


JavaScript



document.addEventListener("selectionchange", function(e) 
console.log("Selection-change Log");
//e.stopPropagation();
console.log(e);
console.warn(e.target.activeElement);


);










share|improve this question

























    up vote
    0
    down vote

    favorite












    Im trying to get the activeTarget of the selectionChange event in IE11 when using the inbuilt search to step through the matches. In firefox and Edge the follow code will log the the element closest to where the element is. So the input "test test" would return the link element.



    In IE11 the log of the whole event will contain the anchor element in the target -> activeElement but when you try to log it it will log event.target.activeElement the body element be logged instead.



    Does anyone know what might be going on and/or how to work around this issue? Helps much appreciated.



    html:



     <html>
    <body>
    <div class="block display-option-100 expandedblock">

    <div class="expand-block block__generic-body" data-expandblock>

    <div class="block__row">

    <div tabindex="0" class="expand-block__clickable-row" role="tab" aria-controls="114428">

    <h2 class="block__heading expand-block__heading ">H55445DEerpfsdfdfs</h2>
    <span class="expand-block__statuslabel" data-nojs-hidden>
    <span class="statuslabel__open"></span>
    <span class="statuslabel__close"></span>
    </span>

    </div>

    <div id="114428" class="expand-block__content" data-expandblockcontent role="tabpanel" aria-expanded="false">

    <p><a title="Här testar vi" href="/testi/">Testitesti Rapport</a></p>
    <p>&nbsp;</p>
    <p><a href="test">herpderp test test</a><br><a href="herp derp">test test jfdsnjdnjf <br></a><a href="fdgfdghfgfdfdg">test tastdsoin tstest</a><br><a href="gfdgfdgfdgfd">yat yat yat yta ggdsggd</a></p>
    </div>

    </div>
    </div>
    </div>
    </body>
    </html>


    JavaScript



    document.addEventListener("selectionchange", function(e) 
    console.log("Selection-change Log");
    //e.stopPropagation();
    console.log(e);
    console.warn(e.target.activeElement);


    );










    share|improve this question























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      Im trying to get the activeTarget of the selectionChange event in IE11 when using the inbuilt search to step through the matches. In firefox and Edge the follow code will log the the element closest to where the element is. So the input "test test" would return the link element.



      In IE11 the log of the whole event will contain the anchor element in the target -> activeElement but when you try to log it it will log event.target.activeElement the body element be logged instead.



      Does anyone know what might be going on and/or how to work around this issue? Helps much appreciated.



      html:



       <html>
      <body>
      <div class="block display-option-100 expandedblock">

      <div class="expand-block block__generic-body" data-expandblock>

      <div class="block__row">

      <div tabindex="0" class="expand-block__clickable-row" role="tab" aria-controls="114428">

      <h2 class="block__heading expand-block__heading ">H55445DEerpfsdfdfs</h2>
      <span class="expand-block__statuslabel" data-nojs-hidden>
      <span class="statuslabel__open"></span>
      <span class="statuslabel__close"></span>
      </span>

      </div>

      <div id="114428" class="expand-block__content" data-expandblockcontent role="tabpanel" aria-expanded="false">

      <p><a title="Här testar vi" href="/testi/">Testitesti Rapport</a></p>
      <p>&nbsp;</p>
      <p><a href="test">herpderp test test</a><br><a href="herp derp">test test jfdsnjdnjf <br></a><a href="fdgfdghfgfdfdg">test tastdsoin tstest</a><br><a href="gfdgfdgfdgfd">yat yat yat yta ggdsggd</a></p>
      </div>

      </div>
      </div>
      </div>
      </body>
      </html>


      JavaScript



      document.addEventListener("selectionchange", function(e) 
      console.log("Selection-change Log");
      //e.stopPropagation();
      console.log(e);
      console.warn(e.target.activeElement);


      );










      share|improve this question













      Im trying to get the activeTarget of the selectionChange event in IE11 when using the inbuilt search to step through the matches. In firefox and Edge the follow code will log the the element closest to where the element is. So the input "test test" would return the link element.



      In IE11 the log of the whole event will contain the anchor element in the target -> activeElement but when you try to log it it will log event.target.activeElement the body element be logged instead.



      Does anyone know what might be going on and/or how to work around this issue? Helps much appreciated.



      html:



       <html>
      <body>
      <div class="block display-option-100 expandedblock">

      <div class="expand-block block__generic-body" data-expandblock>

      <div class="block__row">

      <div tabindex="0" class="expand-block__clickable-row" role="tab" aria-controls="114428">

      <h2 class="block__heading expand-block__heading ">H55445DEerpfsdfdfs</h2>
      <span class="expand-block__statuslabel" data-nojs-hidden>
      <span class="statuslabel__open"></span>
      <span class="statuslabel__close"></span>
      </span>

      </div>

      <div id="114428" class="expand-block__content" data-expandblockcontent role="tabpanel" aria-expanded="false">

      <p><a title="Här testar vi" href="/testi/">Testitesti Rapport</a></p>
      <p>&nbsp;</p>
      <p><a href="test">herpderp test test</a><br><a href="herp derp">test test jfdsnjdnjf <br></a><a href="fdgfdghfgfdfdg">test tastdsoin tstest</a><br><a href="gfdgfdgfdgfd">yat yat yat yta ggdsggd</a></p>
      </div>

      </div>
      </div>
      </div>
      </body>
      </html>


      JavaScript



      document.addEventListener("selectionchange", function(e) 
      console.log("Selection-change Log");
      //e.stopPropagation();
      console.log(e);
      console.warn(e.target.activeElement);


      );







      javascript internet-explorer javascript-events






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 8 at 14:17









      Alun

      92




      92






















          2 Answers
          2






          active

          oldest

          votes

















          up vote
          0
          down vote













          I tried it on both browsers, and it works consistently.



          However, the element needs to have tabindex to be defined as boundary of the activeElement, maybe that is why you saw body element.



          For this it seems to be working on IE11 as well,



          <p width="100%"><a tabindex="0" style="width:100%; display:inline-block;" title="Här testar vi"><span>Testitesti Rapport</span></a></p>





          share|improve this answer








          New contributor




          ad1988 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.

















          • Thanks for your response! This didnt help me it seems though. I get it to return the correct element selecting or highlighting stuff manually. I don't however get it to work when stepping through the search results. Does that work for you? It's still containing the Anchorelement when logging the whole event but when trying the log only that specifik element within the event it logs the body-element. Did you do anything else other than adding tabindex?
            – Alun
            Nov 9 at 7:00


















          up vote
          0
          down vote













          Solved it by using document.getSelection() and then selection.anchorNode.parentNode to get the active element instead if using the event to get the relevant element.



          As seen in the example here: https://chrisdavidmills.github.io/selection-api-examples/






          share|improve this answer




















            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            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',
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            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%2fstackoverflow.com%2fquestions%2f53209606%2fie11-selectionchange-event-activetarget-changes-activetarget-when-logged%23new-answer', 'question_page');

            );

            Post as a guest






























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            0
            down vote













            I tried it on both browsers, and it works consistently.



            However, the element needs to have tabindex to be defined as boundary of the activeElement, maybe that is why you saw body element.



            For this it seems to be working on IE11 as well,



            <p width="100%"><a tabindex="0" style="width:100%; display:inline-block;" title="Här testar vi"><span>Testitesti Rapport</span></a></p>





            share|improve this answer








            New contributor




            ad1988 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
            Check out our Code of Conduct.

















            • Thanks for your response! This didnt help me it seems though. I get it to return the correct element selecting or highlighting stuff manually. I don't however get it to work when stepping through the search results. Does that work for you? It's still containing the Anchorelement when logging the whole event but when trying the log only that specifik element within the event it logs the body-element. Did you do anything else other than adding tabindex?
              – Alun
              Nov 9 at 7:00















            up vote
            0
            down vote













            I tried it on both browsers, and it works consistently.



            However, the element needs to have tabindex to be defined as boundary of the activeElement, maybe that is why you saw body element.



            For this it seems to be working on IE11 as well,



            <p width="100%"><a tabindex="0" style="width:100%; display:inline-block;" title="Här testar vi"><span>Testitesti Rapport</span></a></p>





            share|improve this answer








            New contributor




            ad1988 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
            Check out our Code of Conduct.

















            • Thanks for your response! This didnt help me it seems though. I get it to return the correct element selecting or highlighting stuff manually. I don't however get it to work when stepping through the search results. Does that work for you? It's still containing the Anchorelement when logging the whole event but when trying the log only that specifik element within the event it logs the body-element. Did you do anything else other than adding tabindex?
              – Alun
              Nov 9 at 7:00













            up vote
            0
            down vote










            up vote
            0
            down vote









            I tried it on both browsers, and it works consistently.



            However, the element needs to have tabindex to be defined as boundary of the activeElement, maybe that is why you saw body element.



            For this it seems to be working on IE11 as well,



            <p width="100%"><a tabindex="0" style="width:100%; display:inline-block;" title="Här testar vi"><span>Testitesti Rapport</span></a></p>





            share|improve this answer








            New contributor




            ad1988 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
            Check out our Code of Conduct.









            I tried it on both browsers, and it works consistently.



            However, the element needs to have tabindex to be defined as boundary of the activeElement, maybe that is why you saw body element.



            For this it seems to be working on IE11 as well,



            <p width="100%"><a tabindex="0" style="width:100%; display:inline-block;" title="Här testar vi"><span>Testitesti Rapport</span></a></p>






            share|improve this answer








            New contributor




            ad1988 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
            Check out our Code of Conduct.









            share|improve this answer



            share|improve this answer






            New contributor




            ad1988 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
            Check out our Code of Conduct.









            answered Nov 8 at 17:44









            ad1988

            11




            11




            New contributor




            ad1988 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
            Check out our Code of Conduct.





            New contributor





            ad1988 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
            Check out our Code of Conduct.






            ad1988 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
            Check out our Code of Conduct.











            • Thanks for your response! This didnt help me it seems though. I get it to return the correct element selecting or highlighting stuff manually. I don't however get it to work when stepping through the search results. Does that work for you? It's still containing the Anchorelement when logging the whole event but when trying the log only that specifik element within the event it logs the body-element. Did you do anything else other than adding tabindex?
              – Alun
              Nov 9 at 7:00

















            • Thanks for your response! This didnt help me it seems though. I get it to return the correct element selecting or highlighting stuff manually. I don't however get it to work when stepping through the search results. Does that work for you? It's still containing the Anchorelement when logging the whole event but when trying the log only that specifik element within the event it logs the body-element. Did you do anything else other than adding tabindex?
              – Alun
              Nov 9 at 7:00
















            Thanks for your response! This didnt help me it seems though. I get it to return the correct element selecting or highlighting stuff manually. I don't however get it to work when stepping through the search results. Does that work for you? It's still containing the Anchorelement when logging the whole event but when trying the log only that specifik element within the event it logs the body-element. Did you do anything else other than adding tabindex?
            – Alun
            Nov 9 at 7:00





            Thanks for your response! This didnt help me it seems though. I get it to return the correct element selecting or highlighting stuff manually. I don't however get it to work when stepping through the search results. Does that work for you? It's still containing the Anchorelement when logging the whole event but when trying the log only that specifik element within the event it logs the body-element. Did you do anything else other than adding tabindex?
            – Alun
            Nov 9 at 7:00













            up vote
            0
            down vote













            Solved it by using document.getSelection() and then selection.anchorNode.parentNode to get the active element instead if using the event to get the relevant element.



            As seen in the example here: https://chrisdavidmills.github.io/selection-api-examples/






            share|improve this answer
























              up vote
              0
              down vote













              Solved it by using document.getSelection() and then selection.anchorNode.parentNode to get the active element instead if using the event to get the relevant element.



              As seen in the example here: https://chrisdavidmills.github.io/selection-api-examples/






              share|improve this answer






















                up vote
                0
                down vote










                up vote
                0
                down vote









                Solved it by using document.getSelection() and then selection.anchorNode.parentNode to get the active element instead if using the event to get the relevant element.



                As seen in the example here: https://chrisdavidmills.github.io/selection-api-examples/






                share|improve this answer












                Solved it by using document.getSelection() and then selection.anchorNode.parentNode to get the active element instead if using the event to get the relevant element.



                As seen in the example here: https://chrisdavidmills.github.io/selection-api-examples/







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 9 at 9:03









                Alun

                92




                92



























                     

                    draft saved


                    draft discarded















































                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53209606%2fie11-selectionchange-event-activetarget-changes-activetarget-when-logged%23new-answer', 'question_page');

                    );

                    Post as a guest














































































                    Popular posts from this blog

                    𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

                    Crossroads (UK TV series)

                    ữḛḳṊẴ ẋ,Ẩṙ,ỹḛẪẠứụỿṞṦ,Ṉẍừ,ứ Ị,Ḵ,ṏ ṇỪḎḰṰọửḊ ṾḨḮữẑỶṑỗḮṣṉẃ Ữẩụ,ṓ,ḹẕḪḫỞṿḭ ỒṱṨẁṋṜ ḅẈ ṉ ứṀḱṑỒḵ,ḏ,ḊḖỹẊ Ẻḷổ,ṥ ẔḲẪụḣể Ṱ ḭỏựẶ Ồ Ṩ,ẂḿṡḾồ ỗṗṡịṞẤḵṽẃ ṸḒẄẘ,ủẞẵṦṟầṓế