I knocked together an advent calendar for a friend of mine and I use cookies to store whether or not she has "opened" a door - if she has, it shows a thumbnail of the contents. If she hasn't, it shows the "unopened" background. Now, I've had this working fine on my computer and in Chrome, FF and IE for over a month now.
Unfortunately, my friend isn't having the same result. When she loads the page, it shows as pristine and unopened every time. The thing is, when she clicks on it to "open" the door, it updates to show the thumbnail and if I get her to click on the padlock at the top of the address bar in Chrome, it shows that the cookies have been created and the correct one has been updated. Unfortunately as soon as the page is refreshed, it's somehow overwriting the cookie value.
Before clicking on Door 1 - cookie value is 0
After clicking on Door 1 - cookie value is 1
And yet when she refreshes the page, the cookie value is set back to 0 again.
I have NO idea what would make it do that. There IS a piece of code that checks if a specific cookie exists and if not, creates the list the cookies, but even disabling that script call doesn't stop the problem. If anyone has any ideas, I'd appreciate it because I've tried everything I can think of to make sure the cookies are being set properly and I'm not sure why they aren't persisting for her. I've asked her to check setting for storing cookies, extensions, ad blocking/script blocking stuff, antivirus, etc.
We're both using Chrome on Win 10 - it works for me, but not her.
Thanks in advance, I'm sure its something really simple and I'm just being slow-witted.
The website is here.
Started working spontaneously.
Related
I have a simple html page that displays some monitoring results, it reloads every 2 minutes and makes noise when those results are not acceptable. I keep this page open 24/7, so new Chrome started freezing and suspending it, as I found out via chrome://discards/ .. So the page stopped making noise and catching my attention, mostly cause the tab gets frozen by Chrome. That happens if I forget to leave the tab with this page active, "on top". Is there a rather simple way to prevent Chrome from freezing the tab, even if it is not active? I could involve some Javascript, if needed..
I am aware that there is a simple solution of opening new window with this page and leaving it alone. On the other hand, I made the page, so I can make changes to HTML in order to ensure that page remains unfrozen. I tried updating title with current time on every reload, this visibly helped, page seemingly always has fresh time in the title, but it still doesn't make noise. And if I switch into it when noise is supposed to happen, - it starts the sound half way like it was trying to all alone.. it's even funny..
Is there any simple solution to this? Thanks for your help.
I am working on a project using polymer 3 where I want to destroy/clear a cookie and log out the user from the website. Destroying or clearing cookie is not an issue but I am just not able to detect when the browser closes.
So far I have tried:
window.onbeforeunload
from the JavaScript end and for php have tried this:
session_set_cookie_params(0);
but none are working. Any help would be really appreciable.
I can use setInterval() or setTimeout() function but it's not fulfilling my requirement.
Plz don't suggest any jQuery suggestion.
Use sessionStorage. It Works propably exactly as you want. Whenever user close browser, everything in sessionStorage is removed. Be aware that it works only when user completely close browser. Not only a tab.
I would go the other way around. If the user arrives to the page for the first time, log out the user. You can easily do that by checking if a certain variable is set or not, and then set it whenever the user logs in.
Chrome, by default, discards unused tabs on the background in order to save memory.
I'd like to know if there's a way so I could now if my website was discarded by Chrome - so I could tell my user, next time they go in, instructions on how to avoid that happening (by going to chrome://discards)
Sure, it's not hard to know if my website was closed, but is there any way to be sure it was Chrome saving memory?
2019 update:
In Chrome 68+ you can check for the document.wasDiscarded property.
Source: https://developers.google.com/web/updates/2018/07/page-lifecycle-api
I'm not normally in a need to ask basic or vague JavaScript questions on SO, so pardon me if there is little details here - I'm not sure how to get more.
In the online user manual I'm maintaining, I'm adding custom buttons on each page to get a direct link to the current page (otherwise grabbing the URL just brings you to the home screen), as well as a few extra features. These buttons are added using Javascript, or rather they are already hidden in the HTML, are updated after an AJAX call and then displayed.
It has taken me a lot of work to get these working, in Firefox, Chrome, IE6, 7, 8, 9, I'm sure you know how these things go.
Now comes IE10 with yet another really weird behavior that I want to bang my head on the wall for. If you visit http://help.objectiflune.com/en/knowledgebase/ you will see those buttons on the right inside the main frame. They're grey and blue, top of the page.
So this first "welcome" page is fine, it works great, no issue. However, if you navigate to any sub page using the TOC on the left (such as Error Codes -> PlanetPress Design -> PlanetPress Design Error PXXXX), the buttons all disappear.
I've also noticed that if you get the URL for the page itself (inside the frame, again) and you open it in another tab, it first does not show them, but then refreshing the page makes the buttons appear.
I've tried using the F12 developper console, but it requires refreshing the page to show the console so I can`t use it in those new tabs. As for using within the whole frame system, it doesn't seem to be showing me any errors, nothing weird.
Again I'm sorry if this is an "it's not working" with no further technical details, but... there are none I know how to give.
UPDATE: For the specific code, please turn to http://help.objectiflune.com/common/scripts/olCommon.js , and look at the function starting at line 207 (function buildMenu()). this is the function that retrieves the information and displays the appropriate menus, such as $("#guidebuttons").show();
In ObjectifLune.css, #buttoncontainer has display: none. Navigating through the F12 window, the display of that object is none:
I would guess that somewhere in your JS, you're setting the display to block, but there's something wrong with that code in IE.
I have this functionality built in Jquery/ javascript where a user is notified when their session is about to be timed out. Then they are given an option to extend it. If they don't make a choice the pop up closes itself and the browser is redirected to the login page. It worked perfectly fine for a while. But now I noticed it works correctly only if I am active on the computer. If the computer is left unattended for an entire day, the pop up does not begin the countdown until the user unlocks the computer and logs in again.
Is anybody aware of this behavior where ie stops executing javascript when the computer is left unattended for a long time?
Update: Is there a way to keep the tab from sleeping? Without that, the browser won't be able to redirect at the right time.
setTimeout only works when the tab is active. In some browsers even changing tab will make it stop counting. So not only if you are on the computer but if you're not on the specific page it might not work. Also on mobile devices with multitasking it's bound to fail, forget about tabs, applications often go to suspended mode.
Take a look at this question, it offers the same solution as Luka with a code example:
How can I make setInterval also work when a tab is inactive in Chrome?
You might want to do two checks on the time passed, one to check if you need to show the popup, and one to close the popup, using the total time passed instead of having a different count down.
i would suggest logging the current time when the page is loaded and then calling a function every 10 seconds of so that checks if the time passed is more than x amount, the reason your problem occurs is most likely because the default timeout function only counts down while the page is being rendered.