Show an Alert for Repeating Visitors except New Visitors - javascript

We keep making changes on one of our old site and we need to show an alert for the users who come back / repeating visitors or the users already visited.
Since we made the changes, browsers show the cache site to them and hence it shows broken to them when they visit back after we have made changes.
So, I want to show an alert to ONLY repeating visitors to clear their browsers cache.
I use cookies to store information, I tried to show cookie based alert to the clients, but again that alert was also visible to new visitors too, which is obviously not required as their browser seeing my site for the first time and would not reload the cache site.
Is there any way, I can popup an alert ONLY to my existing or repeating visitors using jquery / javascript / php?

That's a really bad idea. As an user I shouldn't have to care about browser caches or even know what they are. Bothering me with an alert isn't good either.
Consider adding a global "cache busting" parameter to all of your asset URLs, like so:
<link rel="stylesheet" href="style.css?v1">
<script src="script.js?v1"></script>
Then all you have to do is change the version number and all your visitor will see the updated assets without having to do anything special.

Related

to check with JavaScript whether the page is displayed in a browser?

Can I check with JavaScript whether the page is displayed in a browser or as a bookmark Shortcut on the homescreen?
Almost certainly not. The only reasonable way to implement the bookmark on the home screen is to use a snapshot stored locally. Think about it: The device isn't going to visit all of those pages every time you go to the home screen; that would eat up your data transfer allowance, be slow, and irritate people. Instead, it will remember a snapshot of the page as of the last time you visited, store that locally, and use that. (For instance, that's how Chrome for Desktop's New Tab page works showing your popular destinations. That's not the exact same thing, but it's effectively the same use case — and on a desktop browser where extra data transfer isn't usually an issue.)

Chrome extension that would update facebook group page without reloading page

I have been thinking about this but can't figure out due to lack of familarity with how actually facebook is designed to work. If you can help and point me in right direction that would be helpful.
Problem: If you are at a group page and someone post a message you have to reload the page to see the new post. Which is annoying if it turns into chatting.
Possible solutions: that i've come up with..
extension detects new notification...somehow decide if it's about the page we are at, if yes then in background load the page get the new data and add the stuff to the page already opened. (don't know if it's even possible with the extension)
2nd idea is load after detection and confirmation just reload the page and retain all text that's been written and just scroll to that post again. I inspected the post structure it all looked randomly generated string...couldn't tell if any of the class or id were reliable to identify the textbox.
3rd idea is make new page bottom up that relies on some sort of sdk and updates pages as new post come in..(least favorable to me).
4th idea is forget about retaining the text that has been typed, if all inputs are empty and there is new notification reload the page...( i really wish reloading wasn't involved.
You can use the Javascript SDK and an AJAX post. When the server responds, if nothing extraordinary happened (no access token is expired, your facebook app is allowed), then you can handle whatever you want in the callback.

AJAX activities disappear when browsing forward and back

This is not a Meta question.
I am trying to technically understand what principle is hidden behind the following behaviour. It's very easy to reproduce:
Vote up/down anything on this page1,
Click on any other link on this page,
Come back by pressing the back button.
Your upvote is not there anymore as well as any AJAX activities having appeared on the page.
Why is that? Why is the browser acting like so? How could StackOverflow prevent that?
1 If you are not connected, just wait for someone else's activity on the page (new comment, answer, vote) before moving page.
It’s the browser’s cache that is at play here.
Since you’re asked how SO could “prevent” this, it could be done by advising the browser to check for whether the document has changed every time. But SO not doing so, for performance reasons. So the HTML document is seen as “still valid” for a certain amount of time, during which the browser takes it straight from its cache, without making a round-trip to the server.
If you look at the HTTP response headers in your browser’s developer tools for the request your browser made for this page, you will see something like this,
Cache-Control: public, no-cache="Set-Cookie", max-age=60
– so this HTML document is to be considered valid for 60 seconds. If you navigate away from it and back in your browser, or close the tab and reopen it from history, within that 60 seconds, the browser is supposed to take the cached version of it and display it, without checking again with the server whether or not something has changed. And since your vote did not manipulate this original HTML document (only the DOM was updated with your vote), you still get the previous vote count shown.
But if you press [F5] in your browser, the cache will be circumvented – it will request the document from SO again, and then you see your vote, because this time the updated numbers are part of the updated HTML document that SO serves you.
If you want to delve more into HTTP caching, some resources of the top of Google that seem worth a look:
Caching Tutorial for Web Authors and Webmasters
A Beginner's Guide to HTTP Cache Headers
You are not "unvoting", you just are not seeing your vote because your browser is caching the ajax request.
If your press F12 on Chrome, click on Settings icon and then "Disable cache (while DevTools is open)", when you press back the browser will resend the request.
To prevent that you must specify on your code that you never want that specific request to be cached.
You may want to check the following post:
Prevent browser caching of jQuery AJAX call result
-
Ps. You must stay with the Console (F12) opened while doing the test.

GWO: Using trigger Exit page to start test variation

Our marketing team is asking if it is possible to run a test on our site where the variations are shown based on a page exit, versus a page load. I said I could try to see if I could handle it with custom code but I would love to use something already existing. I don't have the knowledge already to trigger a page exit myself and that's what I need to find out.
Scenario: The user would load the page, GWO would decide there which variation to show on load, and when the user "exits" then variation 1 would load a popup. The popup would have a link within it and conversion would be based on the user clicking the link. An exit would be defined here as anyone leaving the domain via the back button, closing the browser, or typing in another address into the address bar. An exit here is not specifically the page but the entire domain itself. Variation 1 of the test would only be served on roughly 10 pages (our of thousands on our retail site).
I somehow think that Google Analytics defines exit already and wonder if I couldn't piggy-bank that trigger? Does GWO have something similar? I don't think it's feasible or logical for our site to track if variation 1 user leaves the domain from any point, so perhaps only tracking exit if they were served variation 1 and only from the same page they got served variation 1.
So I know that's a loaded question, but has it been before within a test? Any easy way to handle it? Thanks in advance!
First off, giving a popup when a visitor is trying to leave your site is horrible UX. It is something that absolutely everybody hates, absolutely no exceptions, period. And...trying to find out which variation of an "exit link popup" works best is like trying to find out which method of torture people like most. So my very first advice to you is I strongly recommend you push back to your Marketing team about this, they should know better...if they are actually suggesting this then maybe they need to be (re)trained (or fired...) Just sayin'...
But anyways... Ga officially states there is no auto-exit link tracking. I know that for the most part, GA determines exit links on current ping vs. next ping (or lack of), but my experience from poking at ga.js leads me to believe they do indeed to some degree have exit link / page unload tracking tucked away in there...
But rather than trying to reverse engineer ga.js to see if it's even possible to tap into something that may or may not really be there, if you have jQuery or similar framework on your page (which most sites do, and if you don't, just include it on your test page(s) easy enough), you can use jQuery's .unload() to get it to trigger as you want.
edit: One thing you said:
An exit here is not specifically the page but the entire domain itself.
Okay that's one "gotcha" that is not possible. You can write code to compare the current URL to the target URL if the visitor clicks on a link on your page, but javascript does not allow for you to access the new URL typed into the address bar, nor does it allow you to see the previous URL in the history (like if user clicks the back button) - both of these are browser security features - so there is no way for you to know 100% if the visitor is exiting your domain.
Tracking tools like GA get around this for some of their data, by having a "session" timer keep track of last activity by the visitor. If the session times out, then the last ping submitted gets the extra data for exiting your site, like "last page of visit", bounce rate numbers, etc.. (though it will not show where the visitor actually went, for reasons listed above)

How can I return home from an a Rails Kiosk Error page without an adress bar or keyboard

Im hosting a rails app on heroku. It runs on the client on a touchscreen with Google Chrome in Kiosk mode, so no browser chrome or keyboard. The login/home page is different for every kiosk.
Error pages are static assets, so I'll have to do this with Javascript. If there is an error I want to display a button that will let the user get back to the home page.
I can't just use a back button script b/c of the potential for multiple errors. I thought about using localstorage to store a reference to the home page, but the error pages are served from a different domain so they wont have access.
Any ideas?
Edit:
This works in Firefox onClick="window.home();" If I set the browser's home page to that particular kiosk. But apparently isn't supported in Chrome. Is there any way to store some kind of variable that any domain can access on a per browser/kiosk basis.
I think you're making this too hard. You already have the information you need to go back stored in "local storage" -- the browser history. Simply use javascript to look at the history and go back as far as you need.
As far as returning to the home page, isn't the home page a well known URI? What's wrong with go home?
Update
Isn't the home page always going to be the first page in the history? You seem to be saying that you're in a situation where you want to return to a page for which you don't know the base URI, don't know how you got where you are, and don't know where you started.
I suppose you could put the place you'd like to go into a cookie, but if you don't even know the base URI, how would you retrieve it?
I'm beginning to think the real answer is "you need to rethink your design, there's something deeply wrong."

Categories