可以通过在每个链接的点击事件中使用window.location.replace()方法来实现页面跳转而URL不变。具体修改如下:

<div class="Polaris-Stack Polaris-Stack--distributionEqualSpacing Polaris-Stack--alignmentCenter" style="margin-top: 1px;border-bottom: 1px #c1c1c1 solid;padding: 5px;">
	<div class="Polaris-Stack__Item">
		<div class="Polaris-Stack Polaris-Stack--spacingTight Polaris-Stack--alignmentCenter">
			<div class="Polaris-Stack__Item">
				<div class="sc-1ibht3l-0 uqRZq"></div>
				<div class="sc-1ibht3l-1 hIZedH">
					<div class="Polaris-ButtonGroup">
						<div class="Polaris-ButtonGroup__Item">
							<a data-polaris-unstyled="true" class="Polaris-Button" href="index.html" onclick="window.location.replace('index.html'); return false;">
								<span class="Polaris-Button__Content">
									<span class="Polaris-Button__Text">Dashboard</span>
								</span>
							</a>
						</div>
						<div class="Polaris-ButtonGroup__Item">
							<a data-polaris-unstyled="true" class="Polaris-Button" href="zone.html" onclick="window.location.replace('zone.html'); return false;">
								<span class="Polaris-Button__Content">
									<span class="Polaris-Button__Text">Checkout Zones</span>
								</span>
							</a>
						</div>
						<div class="Polaris-ButtonGroup__Item">
							<a data-polaris-unstyled="true" class="Polaris-Button" href="funnel.html" onclick="window.location.replace('funnel.html'); return false;">
								<span class="Polaris-Button__Content">
									<span class="Polaris-Button__Text">Funnels</span>
								</span>
							</a>
						</div>
						<div class="Polaris-ButtonGroup__Item">
							<a data-polaris-unstyled="true" class="Polaris-Button" href="help.html" onclick="window.location.replace('help.html'); return false;">
								<span class="Polaris-Button__Content">
									<span class="Polaris-Button__Text">Help Center</span>
								</span>
							</a>
						</div>
						<div class="Polaris-ButtonGroup__Item">
							<div>
								<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;">
									<span class="Polaris-Button__Content">
										<span class="Polaris-Button__Text">More</span>
										<span class="Polaris-Button__Icon">
											<span class="Polaris-Icon">
												<svg viewBox="0 0 20 20" class="Polaris-Icon__Svg" focusable="false" aria-hidden="true">
													<path d="M5 8l5 5 5-5z" fill-rule="evenodd"></path>
												</svg>
											</span>
										</span>
									</span>
									<div id="dropdownContent" class="dropdown-content">
										<a href="payment.html" onclick="window.location.replace('payment.html'); return false;">Payment</a>
										<a href="facebookPixel.html" onclick="window.location.replace('facebookPixel.html'); return false;">Pixel</a>
									</div>
								</button>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>

在每个链接的<a>标签中添加了onclick属性,并且在点击事件中使用window.location.replace()方法来进行页面跳转。通过返回false来阻止默认的链接跳转行为,从而实现URL不变

HTML页面跳转到另一个界面了但是URL不变比说 http127001 我请求 http127001下面的uphtml网页上的url还是 http127001这个怎么实现使用windowlocationreplace修改下面的代码div class=Polaris-Stack Polaris-Stack--distributionEqualSpacing Polaris-Stack--alig

原文地址: https://www.cveoy.top/t/topic/inqO 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录