zhangwei 2 gadi atpakaļ
vecāks
revīzija
0ba6996348
1 mainītis faili ar 31 papildinājumiem un 1 dzēšanām
  1. 31 1
      src/entry/content_iframe.js

+ 31 - 1
src/entry/content_iframe.js

@@ -1 +1,31 @@
-console.log('content_iframe', window.location)
+console.log('content_iframe', window.location)
+
+const _historyWrap = function (type) {
+    const orig = history[type];
+    const e = new Event(type);
+    return function () {
+        const rv = orig.apply(this, arguments);
+        e.arguments = arguments
+        window.dispatchEvent(e)
+        return rv
+    }
+}
+history.pushState = _historyWrap('pushState')
+history.replaceState = _historyWrap('replaceState')
+
+
+window.addEventListener('hashchange', function (event) {
+    console.log('hashchange', event)
+})
+
+window.addEventListener('popstate', function (event) {
+    console.log('popstate', event)
+})
+
+window.addEventListener('pushState', function (e) {
+    console.log('change pushState', e)
+})
+
+window.addEventListener('replaceState', function (e) {
+    console.log('change replaceState', e)
+})