Is there any way to view the local storage of a Windows 8 Store application in debugger?
By : Chong Shao Pin
Date : March 29 2020, 07:55 AM
may help you . Why look in the debugger? You can get the location and then go look in the file using Windows Explorer. Use the debugger to get the location from Windows.Storage.ApplicationData.Current.LocalFolder;
|
How do you access a Metro app's local storage in a desktop application in Windows 8?
By : Manoj Rawat
Date : March 29 2020, 07:55 AM
|
Store and retrieve data from local storage using chrome storage API
By : user2977340
Date : March 29 2020, 07:55 AM
seems to work fine First of all, you don't need to use the chrome.storage API to make this work. By the way, unfortunately, what you're looking for does not exist. You are looking for some event (like onBrowserClosed) that isn't implemented in the Chrome APIs. A bug report has been made HERE (although it actually isn't a bug), if you want to stay updated you can star it. Although, you can still approach the problem with a setInterval(), that will execute your function to update the time a user has spent on a site every certain interval (in milliseconds), and will stop when the browser is closed. Something like this: code :
var currentActiveTab, chromeHasFocus = false;
localStorage.timeSpentOnSites = localStorage.timeSpentOnSites || "{}";
// get the first tab at startup
chrome.tabs.query({active: true, highlighted: true}, function(tabs) {
currentActiveTab = tabs[0];
console.log('New active tab:', tabs[0]);
});
// this will keep currentActiveTab updated to always be the active tab (the one that the user is watching)
chrome.tabs.onUpdated.addListener(function(tabID, info, tab) {
if (tab.active && tab.highlighted) currentActiveTab = tab;
console.log('New active tab:', tab);
});
// this also
chrome.tabs.onActivated.addListener(function(info) {
chrome.tabs.query({active: true, highlighted: true}, function(tabs) {
currentActiveTab = tabs[0];
console.log('New active tab:', tabs[0]);
});
});
// this will check if chrome is active or not
chrome.windows.onFocusChanged.addListener(function(windowID) {
if (windowID === chrome.windows.WINDOW_ID_NONE) {
chromeHasFocus = false;
console.log('Chrome lost focus.');
} else if (!chromeHasFocus) {
chromeHasFocus = true;
console.log('Chrome has focus.');
}
});
function addTimeSpentOnSite(site) {
var T = JSON.parse(localStorage.timeSpentOnSites);
// if site already exists increment the time spent on it
if (T[site]) T[site]++;
// otherwise set the time spent on it as 1 (second)
else T[site] = 1;
localStorage.timeSpentOnSites = JSON.stringify(T);
}
setInterval(function() {
if (!chromeHasFocus) return;
// if the chrome window isn't active the user is not watching the site
var site = currentActiveTab.url.split('/')[2];
// get the site name, something like www.site.com
addTimeSpentOnSite(site);
// increase the amount of time spent on the site
}, 1000);
|
Clear local storage when user closes window
By : Ashley
Date : March 29 2020, 07:55 AM
I hope this helps . How Do I clear local storage when my website is closed in all the tabs in a browser? means If my user is open my website in multiple tabs, and when user is close browser or close tabs one by one, I need to clear local storage on last tab close event (e.g. on "beforeunload" event). , This is how you do it:
|
Clear local storage when the browser closes in angular
By : Liu Lei
Date : March 29 2020, 07:55 AM
I wish this helpful for you I have created an angular 5 application. Which is using a token based system.Currently I am storing the token in the localstorage.I want the localstorage to be clear when the browser closes. and not clear the localstorage when the browser refreshes.The reason that I didn't use sesionstorage is because opening a page in a new tab or window will cause a new session to be initiate. How can I done this I tried with this code in app.component , You should do that way... code :
import { Component, HostListener } from "@angular/core";
@Component({
selector: 'app-root',
templateUrl:"./app/app.component.html"
})
export class AppComponent {
@HostListener("window:onbeforeunload",["$event"])
clearLocalStorage(event){
localStorage.clear();
}
}
|