src/widgets/Mediafragment.js
branchnew-model
changeset 910 b9f1bd52df9a
parent 906 4b6e154ae8de
child 916 ec6849bbbdcc
--- a/src/widgets/Mediafragment.js	Tue Jun 05 17:55:24 2012 +0200
+++ b/src/widgets/Mediafragment.js	Tue Jun 05 20:55:42 2012 +0200
@@ -6,7 +6,7 @@
     if (typeof window.addEventListener !== "undefined") {
         window.addEventListener('message', function(_msg) {
             if (/^#/.test(_msg.data)) {
-                document.location.hash = _msg.data;
+                this.setWindowHash(_msg.data);
             }
         })
     };
@@ -22,6 +22,14 @@
     this.goToHash();
 }
 
+IriSP.Widgets.Mediafragment.prototype.setWindowHash = function(_hash) {
+    if (typeof window.history !== "undefined" && typeof window.history.replaceState !== "undefined") {
+        window.history.replaceState({}, "", _hash);
+    } else {
+        document.location.hash = _hash;
+    }
+}
+
 IriSP.Widgets.Mediafragment.prototype.getLastHash = function() {
     var _tab = document.location.hash.replace(/^#/,'').split('&');
     _tab = IriSP._(_tab).filter(function(_el) {
@@ -71,7 +79,7 @@
         this.last_hash_key = _key;
         this.last_hash_value = _value;
         var _hash = this.getLastHash();
-        document.location.hash = _hash;
+        this.setWindowHash(_hash);
         if (window.parent !== window) {
             window.parent.postMessage(_hash,"*")
         }