Rails 7 - Opening initial window and closing after n seconds - javascript

First, I will start out saying I understand the concept that a window not opened by you with JavaScript cannot be closed by you using window.close(). What I am wondering is if in Rails (Rails-7 for me), is there a way, perhaps using an initialize script, to open the default window using window.open(). What I am trying to accomplish is, a user scans a QR code that directs to another path in my routes, it will display a message and screen colour change for 10 seconds. At this point, I want that tab plus the initial opening default tab to close, and the application is then closed. The second tab is no problem but I need to be able to close the beginning tab as well, otherwise, the user will end up with a new tab for every QR they scan, which could result in hundreds in the course of a day. Thanks in advance for any input.

Related

Manage Chrome Browser Tabs and screen arrangement

I have a use case in which I have to open an URL from Application A which is a SaaS web application. and during it's session Application A can request many URLs to open one by one but all should open in Same Browser Window Tab which was established on first click, in case Browser window is closed accidently next click will open it and subsequent URL request will open in same tab.
Second piece to this is opening on Screen 2 as i have dual monitor setup.
For use case one I was trying something by windows.open and naming that window it works one time next time open two new windows.
Please guide if this is possible? or if any other alternative framework which can help achieve this?

Chrome Window X event with Locking [duplicate]

This question already has answers here:
Run JavaScript code on window close or page refresh?
(8 answers)
Closed 1 year ago.
I have a site I'm building where a user clicks a row from a datagrid and it opens a new Chrome window with a form filled with data from the row. I only want one user editing the data at a time so if another user gets in, the screen is read-only. I do this by setting a LockUserID and LockDate on the row after a user enters. The minute the first user (lockuser) saves the data it will close the window and null out the LockUserID and LockDate so then next person can get in.
My problem is if a user clicks the chrome x button I don't know that the user left therefore the LockUserID and LockDate still have a value on the row and anyone that gets in afterward will have a read only view.
I have tried using before unload but this almost feels like a hack considering beforeunload is used for refreshing and other events.
Does anyone have any better suggestions with locking?
Maybe you can send a regular AJAX request to the server. Let's say every 30 seconds. The server saves the time. When a new user tries to open the side you can check if the interval is bigger between the last incoming request and the current time than the 40 seconds and if so unlock the site.
Not the best solution i think but it should work
Or the better solution: Run JavaScript code on window close or page refresh?

block current window for n seconds with JS

I am developping a web app using backboneJs and nodeJS, I want to oblige the user to not close this current window for 10 seconds, after 10 seconds he can do whatever he likes. Is it possible with JS?
The window settings are controlled by your browser (Chrome/Firefox/Safari etc.). So anything that lies beyond what appears on the website screen is not in our control.
Incase you want to ensure the user reads a particular message for a given timestamp, I suggest using popovers or a custom landing page should be of good use.

Identifying Tab / Window to click a button using JavaScript (AppleScript)

I am trying to get an Apple Script to click on an item within webpage.
I'm using the following script
tell application "Safari"
delay 5
do JavaScript "document.getElementById('Menu Principal').click();" in current tab of first window
end tell
However my output us "missing value". I think that the problem is that I'm not selecting the right tab or window to click at.
This is my first time using applescript and other examples and question in Stackoverflow are somewhat similar but I'm still missing something
I'm attaching the webpage source code.
Thanks!
http://s328.photobucket.com/user/sergioguerra1/media/ScreenShot2014-03-13at114430AM_zps6919a8ce.png.html

how we can restrict user to click or go on the browser window until they close the opened pop up window?

I am making a web application which takes the exam related programming languages, and i am opening a pop up window for test when a user click to start a test ,
but i want to restrict them to go on the main broweser window until they submit the exam(pope up window closed automatically) or they will close manualy
As far as i know its not possible with javascript. but cant you better use a box that will lay on top of the original page content like you can do with Jquery.
http://jqueryui.com/dialog/#modal-form
Removing the buttons and other forms of cancelation and only leave a post button when all answers are given.

Categories

Resources