You could try to modify your code as below:
<a href="#top" data-value="linkA"> Link A</a><br />
<a href="#middle" data-value="linkB"> Link B</a><br />
<a href="#bottom" data-value="linkC"> Link C</a><br />
<div id="top" style="width:100%; height:600px; background-color:antiquewhite">
Top
</div>
<div id="middle" style="width:100%; height:600px; background-color:aqua">
Middle
</div>
<div id="bottom" style="width:100%; height:600px; background-color:aquamarine">
Bottom
</div>
<script type="text/javascript">
var forEach = Array.prototype.forEach;
var anchors = document.querySelectorAll('a[href^="#"]');
forEach.call(anchors, function (anchor) {
anchor.addEventListener('click', function (e) {
e.preventDefault();
//get the a tag attribute.
alert(e.srcElement.getAttribute("data-value"));
//document.querySelector(e.srcElement.getAttribute('href')).scrollIntoView({
// behavior: 'smooth'
//});
});
});
</script>
The output like this (works well on IE, Chrome and Edge).
Besides, please check your code, if we want to get the attribute in the anchor click event, we should use the 'e.srcElement.getAttribute()' method.