tekton Posted November 8, 2014 Share Posted November 8, 2014 Hello , everyone. Was wondering if you can put a single popup that could appear to many visitors to a site at the same time , regardless of the page you 're browsing . Is there a chance to do it in JavaScript or another language ? Hwo could i do it? Iappreciate the help . Link to comment Share on other sites More sharing options...
niche Posted November 8, 2014 Share Posted November 8, 2014 What would trigger it? Link to comment Share on other sites More sharing options...
dsonesuk Posted November 9, 2014 Share Posted November 9, 2014 JavaScript clock, so when it reaches specific time, 'merry blah blah', but you have to allow for time zones. Link to comment Share on other sites More sharing options...
niche Posted November 9, 2014 Share Posted November 9, 2014 (edited) That's why I asked about the trigger. dsonesuk, what if the trigger is situational (not time sensitive)? Let's say a bad storm is heading towards us and 50 users are deciding what to buy on various pages of a site (pages that have already loaded). I can't imagine how to force a pop up after the page is loaded (with code that wasn't in the page when it loaded). Is that possible? If so, how generally? Edited November 9, 2014 by niche Link to comment Share on other sites More sharing options...
dsonesuk Posted November 9, 2014 Share Posted November 9, 2014 Ha ha, So bad storm heading toward you, and with phone, TV, etc warning you about the storm also neighbours running around frantically outside, you! rather than find place of safety, or secure your property, are more interested in buying stuff so you will look good in the storm, this would be a evolution scenario, where the idiots die, and people with common sense would survive :-) . Link to comment Share on other sites More sharing options...
niche Posted November 9, 2014 Share Posted November 9, 2014 It was just an example. So, it seems you're limited to the code that that's loaded. Link to comment Share on other sites More sharing options...
dsonesuk Posted November 9, 2014 Share Posted November 9, 2014 I suppose you could use ajax to check server for a specific situation at certain intervals, if it occurs, force reload of page, which could then load popup script, alert or whatever. 1 Link to comment Share on other sites More sharing options...
niche Posted November 9, 2014 Share Posted November 9, 2014 Very cool dsonesuk. Thanks. Link to comment Share on other sites More sharing options...
Hadien Posted November 9, 2014 Share Posted November 9, 2014 (edited) Basically, it sounds to me you want to implement the same technologies used in Chat rooms. When people connect to a web page with an imbedded Chat plugin, it "subscribes" with server so that the server knows who is currently online at the time. eventually the subscription will expire on its own, disconnecting the user, unless the plug-in renews the subscription with the server (which they do automatically as long as the program remains open). In a chat room when someone inputs text, the text is transferred to the server and the server then announces the text to all other users currently subscribed to the server. Those that left the page have technically unsubscribed so the server won't send any data to them. What you want is something similar, but without the user input. What you want is for when users view a page they automatically subscribe to the server for a minute or so, renewing the subscription every minute they remain on the site. and when you type out a file to send, the server then publishes the file and sends it to everyone currently registered. You then have javascript or whatever plugin your running to capture the announcement and process it so that it can be displayed. This Observer pattern should pose the least overhead to the system, each user simply sends notification that they are still there, not requesting any data. and when some news does arrive the server knows exactly who is able to see it. another method is to use an RSS feed which requires the user to reload the page. Otherwise it fully meets the criteria you want. yet another option is to have an invisible iframe that periodically (once per minute is likely ideal) requests the news feed. by abusing the last-modified attribute and sessionstorage, each user will know if they have seen the news before. If so, then last-modified ensures the server isn't wasting bytes on sending them old news while client side the onload event is suppressed since last-modified matches what is in the session storage. If the info IS new to them, the server sends the new page to them, session storage updates to the current last-modified date, and the page's onload event runs creates a popup. Just like the RSS choice the update isn't instant as each client has to proactively request the news themselves, and since each client is not aware of each other they won't have synchronized updates. Edited November 9, 2014 by Hadien Link to comment Share on other sites More sharing options...
davej Posted November 9, 2014 Share Posted November 9, 2014 I think this article on HTML5 websockets is relevant... http://www.html5rocks.com/en/tutorials/websockets/basics/ https://developer.mozilla.org/en-US/docs/WebSockets Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now