HTML页面跳转不改变URL - 使用window.location.replace()方法
///'可以通过在每个链接的点击事件中使用window.location.replace()方法来实现页面跳转而URL不变。具体修改如下://n//nhtml//n<div class=/'Polaris-Stack Polaris-Stack--distributionEqualSpacing Polaris-Stack--alignmentCenter/' style=/'margin-top: 1px;border-bottom: 1px #c1c1c1 solid;padding: 5px;/'>//n//t<div class=/'Polaris-Stack__Item/'>//n//t//t<div class=/'Polaris-Stack Polaris-Stack--spacingTight Polaris-Stack--alignmentCenter/'>//n//t//t//t<div class=/'Polaris-Stack__Item/'>//n//t//t//t//t<div class=/'sc-1ibht3l-0 uqRZq/'></div>//n//t//t//t//t<div class=/'sc-1ibht3l-1 hIZedH/'>//n//t//t//t//t//t<div class=/'Polaris-ButtonGroup/'>//n//t//t//t//t//t//t<div class=/'Polaris-ButtonGroup__Item/'>//n//t//t//t//t//t//t//t<a data-polaris-unstyled=/'true/' class=/'Polaris-Button/' href=/'index.html/' onclick=/'window.location.replace('index.html'); return false;/'>//n//t//t//t//t//t//t//t//t<span class=/'Polaris-Button__Content/'>//n//t//t//t//t//t//t//t//t//t<span class=/'Polaris-Button__Text/'>Dashboard</span>//n//t//t//t//t//t//t//t//t</span>//n//t//t//t//t//t//t//t</a>//n//t//t//t//t//t//t</div>//n//t//t//t//t//t//t<div class=/'Polaris-ButtonGroup__Item/'>//n//t//t//t//t//t//t//t<a data-polaris-unstyled=/'true/' class=/'Polaris-Button/' href=/'zone.html/' onclick=/'window.location.replace('zone.html'); return false;/'>//n//t//t//t//t//t//t//t//t<span class=/'Polaris-Button__Content/'>//n//t//t//t//t//t//t//t//t//t<span class=/'Polaris-Button__Text/'>Checkout Zones</span>//n//t//t//t//t//t//t//t//t</span>//n//t//t//t//t//t//t//t</a>//n//t//t//t//t//t//t</div>//n//t//t//t//t//t//t<div class=/'Polaris-ButtonGroup__Item/'>//n//t//t//t//t//t//t//t<a data-polaris-unstyled=/'true/' class=/'Polaris-Button/' href=/'funnel.html/' onclick=/'window.location.replace('funnel.html'); return false;/'>//n//t//t//t//t//t//t//t//t<span class=/'Polaris-Button__Content/'>//n//t//t//t//t//t//t//t//t//t<span class=/'Polaris-Button__Text/'>Funnels</span>//n//t//t//t//t//t//t//t//t</span>//n//t//t//t//t//t//t//t</a>//n//t//t//t//t//t//t</div>//n//t//t//t//t//t//t<div class=/'Polaris-ButtonGroup__Item/'>//n//t//t//t//t//t//t//t<a data-polaris-unstyled=/'true/' class=/'Polaris-Button/' href=/'help.html/' onclick=/'window.location.replace('help.html'); return false;/'>//n//t//t//t//t//t//t//t//t<span class=/'Polaris-Button__Content/'>//n//t//t//t//t//t//t//t//t//t<span class=/'Polaris-Button__Text/'>Help Center</span>//n//t//t//t//t//t//t//t//t</span>//n//t//t//t//t//t//t//t</a>//n//t//t//t//t//t//t</div>//n//t//t//t//t//t//t<div class=/'Polaris-ButtonGroup__Item/'>//n//t//t//t//t//t//t//t<div>//n//t//t//t//t//t//t//t//t<button type=/'button/' id=/'moreSeting/' class=/'Polaris-Button/' tabindex=/'0/' aria-controls=/'Popover486/' aria-owns=/'Popover486/' aria-haspopup=/'true/' aria-expanded=/'false/' onclick=/'window.location.replace('payment.html'); return false;/'>//n//t//t//t//t//t//t//t//t//t<span class=/'Polaris-Button__Content/'>//n//t//t//t//t//t//t//t//t//t//t<span class=/'Polaris-Button__Text/'>More</span>//n//t//t//t//t//t//t//t//t//t//t<span class=/'Polaris-Button__Icon/'>//n//t//t//t//t//t//t//t//t//t//t//t<span class=/'Polaris-Icon/'>//n//t//t//t//t//t//t//t//t//t//t//t//t<svg viewBox=/'0 0 20 20/' class=/'Polaris-Icon__Svg/' focusable=/'false/' aria-hidden=/'true/'>//n//t//t//t//t//t//t//t//t//t//t//t//t//t<path d=/'M5 8l5 5 5-5z/' fill-rule=/'evenodd/'></path>//n//t//t//t//t//t//t//t//t//t//t//t//t</svg>//n//t//t//t//t//t//t//t//t//t//t//t</span>//n//t//t//t//t//t//t//t//t//t//t</span>//n//t//t//t//t//t//t//t//t//t</span>//n//t//t//t//t//t//t//t//t//t<div id=/'dropdownContent/' class=/'dropdown-content/'>//n//t//t//t//t//t//t//t//t//t//t<a href=/'payment.html/' onclick=/'window.location.replace('payment.html'); return false;/'>Payment</a>//n//t//t//t//t//t//t//t//t//t//t<a href=/'facebookPixel.html/' onclick=/'window.location.replace('facebookPixel.html'); return false;/'>Pixel</a>//n//t//t//t//t//t//t//t//t//t</div>//n//t//t//t//t//t//t//t//t</button>//n//t//t//t//t//t//t//t</div>//n//t//t//t//t//t//t</div>//n//t//t//t//t//t</div>//n//t//t//t//t</div>//n//t//t//t</div>//n//t//t</div>//n//t</div>//n</div>//n//n//n在每个链接的<a>标签中添加了onclick属性,并且在点击事件中使用window.location.replace()方法来进行页面跳转。通过返回false来阻止默认的链接跳转行为,从而实现URL不变。///
原文地址: https://www.cveoy.top/t/topic/p5ow 著作权归作者所有。请勿转载和采集!