My challenge involves a URL http://localhost:8080/?london that needs to load directly to the element with an id of london in the HTML section <section id="london">
on the page.
Using http://localhost:8080/#london is not an option, even though it would work for this purpose!
To add complexity, I am working within a Vue framework and instructed to write the necessary code inside master-origin/src/assets/js/mixins/Anchor.js - thus, I cannot use jQuery and must rely on vanilla JavaScript.
I attempted the following:
var el = [];
el = window.location.href.split("/?")[1];
console.log("el: " + el);
el.scrollIntoView();
This script successfully extracts the value after /?, but when attempting to use scrollIntoView, the console displayed the error message:
TypeError: el.scrollIntoView is not a function at VM10022 IE work:4
The reason behind this error remains unclear. I followed guidance from W3Schools found at https://www.w3schools.com/jsref/met_element_scrollintoview.asp