Quantcast
Channel: Internet Explorer Web Development forum
Viewing all articles
Browse latest Browse all 3527

binding selection event no use in Edge engine

$
0
0

Hello, I am debugging a js event now on the edge engine.

I found that some issue in edge but not in the Internet explorer11:

1.after using IE11 and edge and these all finished loaded ,the addrange method is ok.

2.1 using ie11 and binding event in the dom,addrange in bind event it's ok.

2.2 using edge and binding event in the dom,,addrange in bind event it's no use.

And Is it another solution for solve this problem?

that my code( you can use it directly in edge and the ie11 and you will know what I found):

<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8" />
    <title></title>
    <script>
       
        function dosth()
        {
            var strongs = document.getElementsByTagName("img");
            var winSelection = document.getSelection();
            winSelection.removeAllRanges();
           
            for (var i = 0; i < strongs.length; i++)
            {
                strongs[i].onclick = function (event)
                {
                    var varRange = document.createRange();
                    varRange.selectNode(this);
                    winSelection.addRange(varRange);
                   
                    return false;
                }
               
            }
           
            var varRange = document.createRange();
            varRange.selectNode(strongs[1]);
            winSelection.addRange(varRange);           
        }
       
    </script>
</head>
<body>
    <strong>123</strong>
    <strong>456</strong>
    <strong>789</strong>
    <strong>321</strong>
    <strong>546</strong>
    <strong>874</strong>
    <strong>541</strong>
    <img src="http://f.picphotos.baidu.com/album/s%3D1000%3Bq%3D90/sign=642a1de2d7a20cf44290fadf46397047/5bafa40f4bfbfbed96ccac1a7ff0f736afc31f39.jpg"/>
    <img src="http://f.picphotos.baidu.com/album/s%3D1000%3Bq%3D90/sign=642a1de2d7a20cf44290fadf46397047/5bafa40f4bfbfbed96ccac1a7ff0f736afc31f39.jpg" />
    <img src="http://f.picphotos.baidu.com/album/s%3D1000%3Bq%3D90/sign=642a1de2d7a20cf44290fadf46397047/5bafa40f4bfbfbed96ccac1a7ff0f736afc31f39.jpg" />
    <img src="http://f.picphotos.baidu.com/album/s%3D1000%3Bq%3D90/sign=642a1de2d7a20cf44290fadf46397047/5bafa40f4bfbfbed96ccac1a7ff0f736afc31f39.jpg" />
    <script>
    dosth();
    </script>
</body>
</html>


Viewing all articles
Browse latest Browse all 3527

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>