滚动到指定位置
html
<div id="锚点id"></div>
js
const insertLink = (val) => {
var a = document.createElement("a");
let href = val;
a.setAttribute("href", href);
a.setAttribute("target", "_blank");
a.setAttribute("id", "startTelMedicine");
a.onclick = function () {
//关闭窗口的方法
window.opener = null;
window.open("", "_self", "");
window.close();
};
// 防止反复添加
if (document.getElementById("startTelMedicine")) {
document.body.removeChild(document.getElementById("startTelMedicine"));
}
document.body.appendChild(a);
a.click();
};
css
html,body{
scroll-behavior:smooth;//页面滚动时动画
}