fixed back button on marketplace

This commit is contained in:
kunalgosar 2017-03-21 14:12:54 -07:00
parent 13222468e3
commit a4af973ae4
2 changed files with 15 additions and 4 deletions

View file

@ -26,6 +26,8 @@
var xmlHttpRequest = null; var xmlHttpRequest = null;
var isPreparing = false; // Explicitly track download request status. var isPreparing = false; // Explicitly track download request status.
var lastPage = "https://metaverse.highfidelity.com/marketplace?";
function injectCommonCode(isDirectoryPage) { function injectCommonCode(isDirectoryPage) {
// Supporting styles from marketplaces.css. // Supporting styles from marketplaces.css.
@ -65,7 +67,7 @@
// Footer actions. // Footer actions.
$("#back-button").on("click", function () { $("#back-button").on("click", function () {
window.history.back(); window.location = lastPage;
}); });
$("#all-markets").on("click", function () { $("#all-markets").on("click", function () {
EventBridge.emitWebEvent(GOTO_DIRECTORY); EventBridge.emitWebEvent(GOTO_DIRECTORY);
@ -342,7 +344,12 @@
} }
} }
function locationChanged() {
lastPage = location.href;
}
// Load / unload. // Load / unload.
window.addEventListener("load", onLoad); // More robust to Web site issues than using $(document).ready(). window.addEventListener("load", onLoad); // More robust to Web site issues than using $(document).ready().
window.addEventListener("hashchange", locationChanged);
}()); }());

View file

@ -69,7 +69,11 @@
function onWebEventReceived(event) { function onWebEventReceived(event) {
print("Script received a web event, its type is " + typeof event); print("Script received a web event, its type is " + typeof event);
if (typeof event === "string") { if (typeof event === "string") {
try {
event = JSON.parse(event); event = JSON.parse(event);
} catch(e) {
return;
}
} }
if (event.type === "ready") { if (event.type === "ready") {
// send username to html // send username to html