web/res/metadataplayer/Mediafragment.js
changeset 638 e0d4e8431de3
parent 621 44f90de0016f
child 694 e9400c80e1e4
--- a/web/res/metadataplayer/Mediafragment.js	Thu Jun 14 16:05:27 2012 +0200
+++ b/web/res/metadataplayer/Mediafragment.js	Wed Jun 20 18:46:56 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) {
@@ -57,7 +65,7 @@
 }
 
 IriSP.Widgets.Mediafragment.prototype.setHashToAnnotation = function(_annotationId) {
-    this.setHash( 'id', this.source.unNamespace(_annotationId) );
+    this.setHash( 'id', _annotationId );
 }
 
 IriSP.Widgets.Mediafragment.prototype.setHashToTime = function(_time) {
@@ -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,"*")
         }