关于更改浏览器URL调用javascript函数 [英] on change of browser url call javascript function

查看:123
本文介绍了关于更改浏览器URL调用javascript函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好



i需要调用javascript函数更改浏览器url假设用户从浏览器栏更改url然后在任何事情发生之前javascript函数应该先调用

解决方案



据我所知,当用户从浏览器栏更改URL时,没有可能的函数调用。



您可以尝试使用onpageunload函数获取不匹配的URL序列。


在上面提到的场景中,JavaScript中没有事件存在。您可以尝试 window.onbeforeunload 在窗口即将卸载时被触发的事件,但是如果用户刷新页面并且您需要自己处理,此事件也会触发。请查看以下链接以供参考



window.onbeforeunload [ ^ ]

Hello

i need to call javascript function on change of browser url suppose user change url from browser bar then before anything happens javascript function should be call first

解决方案

Hi,
From my knowledge there is no possible functions to call when user changes the URL from browser bar.

You can try with onpageunload function for unmatching sequence of URL.


Well there is no event exist in JavaScript for above mentioned scenario.You can try window.onbeforeunload event which get fired when a window is about to unload but this event will also get fire in case user refresh the page and that you need to handle yourself. Check below link for reference

window.onbeforeunload[^]


这篇关于关于更改浏览器URL调用javascript函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆