1 - What is correct syntax for WebKit (primary for Safari on iPad, good if it works on Win Chrome) to .addEventListener
to hashChange
event?
2 - Is is possible (and how) to manually/programmatically dispatch hashChange event by .dispatchEvent
on browsers mentioned above?
TIA.
I've found answer for 1:
window.addEventListener("hashchange", function() {console.log(location.hash)});
But I still have no idea how to dispatch hashchange
manual since I don't know what EVENTOBJECT
I should pass to window.dispatchEvent(EVENTOBJECT)
.
If you want to force hashchcange event without literaly changing hash you should call:
window.dispatchEvent(new HashChangeEvent("hashchange"))
Object passed to the event handler will have this props available:
String oldURL;
String newURL;
This is an only info I found about this:
https://github.com/WebKit/webkit/blob/master/Source/WebCore/dom/HashChangeEvent.h
after receiving answer here:
http://forum.php.pl/index.php?showtopic=213470
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With