Jquery 我对window.history.pushState有问题
当visiter从浏览器单击back时,我试图重定向到另一个url,我使用了下面的代码并将其放入single.php(我只希望代码在post上工作)。代码工作得很好,但它在/gclid=之后清除了Adword id JqueryJquery 我对window.history.pushState有问题,jquery,wordpress,Jquery,Wordpress,当visiter从浏览器单击back时,我试图重定向到另一个url,我使用了下面的代码并将其放入single.php(我只希望代码在post上工作)。代码工作得很好,但它在/gclid=之后清除了Adword id Jquery <script src="https://code.jquery.com/jquery-3.5.1.js" integrity="sha256-QWo7LDvxbWT2tbbQ97B53yJnYU3WhH/C8ycbRAkjP
<script
src="https://code.jquery.com/jquery-3.5.1.js"
integrity="sha256-QWo7LDvxbWT2tbbQ97B53yJnYU3WhH/C8ycbRAkjPDc="
crossorigin="anonymous"></script>
<script>
window.history.pushState(null, null, './');
$(window).on('popstate', function() {
location.href = "/";
});
<script>
window.history.pushState(null,null,'./');
$(窗口).on('popstate',function()){
location.href=“/”;
});
对于浏览器返回事件,您使用以下代码:
目前,我已将重定向设置为google
<script type="text/javascript">
jQuery(function() {
if ( window.history && window.history.pushState ) {
window.history.pushState('', null, './');
jQuery(window).on('popstate', function() {
// alert('Back button was pressed.');
document.location.href = 'https://www.google.com';
});
}
});
</script>
jQuery(函数(){
if(window.history&&window.history.pushState){
window.history.pushState(“”,null,./');
jQuery(window).on('popstate',function()){
//警报('按下后退按钮');
document.location.href=https://www.google.com';
});
}
});
注意:如果您需要在.JS文件中添加此代码,请忽略
标记。您想要任何特定浏览器还是所有浏览器?所有浏览器my bro!