Block Browser Refresh
-
- Profound User
- Posts: 72
- Joined: Fri May 08, 2009 2:43 pm
- First Name: David
- Last Name: Esdale
- Company Name: Guardian General Insurance
- City: Port of Spain
- State / Province: Outside Canada/USA
- Country: Trinidad and Tobago
- Location: Trinidad
- Contact:
Block Browser Refresh
Is there any way for Atrium to Block (or at least request confirmation) of a browser refresh initiated by the F5 key. From the 5250, our users are in the habit of using the F5 key to refresh a screen/page. When they are on a non-Genie web page in Atrium and they press F5, Atrium reloads and they have to sign back into Atrium.
- David
- Profound Logic Staff Member
- Posts: 690
- Joined: Fri Jan 04, 2008 12:11 pm
- First Name: David
- Last Name: Russo
- Company Name: Profound Logic Software
- Contact:
Re: Block Browser Refresh
Currently there is no option to do this in Atrium. We may add this feature in a future release.
In the meanwhile, a script running in any one of your pages launched in Atrium could assign such an event.
For example, if you are running Genie screens from Atrium, code in your "custom.js" file could do the work.
There is no way for a browser application to prevent the user from navigating away from the current page (makes sense if you think about it), but you can have the browser display a warning and force the user to confirm before this happens. The following code will do it:
If you are running Genie with the "confirm on close" or "auto disconnect" options in effect, Genie will be running in a frameset and you may need to use "parent.parent" as opposed to "parent".
The browser will force the user to confirm before navigating away. It will display 2 lines of standard text (which you cannot control), and it will place the string returned by your function in between those 2. If you want no message of your own, simply return an empty string from the function.
In the meanwhile, a script running in any one of your pages launched in Atrium could assign such an event.
For example, if you are running Genie screens from Atrium, code in your "custom.js" file could do the work.
There is no way for a browser application to prevent the user from navigating away from the current page (makes sense if you think about it), but you can have the browser display a warning and force the user to confirm before this happens. The following code will do it:
Code: Select all
parent.onbeforeunload = function() {
return "My message.";
}
The browser will force the user to confirm before navigating away. It will display 2 lines of standard text (which you cannot control), and it will place the string returned by your function in between those 2. If you want no message of your own, simply return an empty string from the function.
-
- Profound User
- Posts: 22
- Joined: Fri Jan 29, 2016 11:15 am
- First Name: sam
- Last Name: huffman
- Company Name: gmdsolutions
- Phone: 7122624520
- Address 1: 2311 W 18th ST
- City: Spencer
- State / Province: Iowa
- Zip / Postal Code: 51301
- Country: United States
- Contact:
Re: Block Browser Refresh
Old thread i know... but i have the same issue and i think i have a solutions that works. I'm not a huge fan of the onbeforeunload event so i came up with this.
This is intended to disable all function keys when not inside an application that was launched from atrium and has only been tested in ProfoundUI v5.6 and Chrome v54.0.2840.99
In the atrium javascript extension located on the IFS at '/www/yourinstance/htdocs/profoundui/userdata/extension/atrium/settings.js' depending on your instance name.
Note: i believe the settings.js file needs to be created if it doesn't already exist. More info here: http://www.profoundlogic.com/docs/displ ... ecific+API
This is a function you can add to the atrium onload event to stop the function keys. If you're not already familiar with the settings.js extention of atrium you will only need to create the file and include this code. Otherwise just add the function and function call to the onload event.
As an extra precaution: The atrium banner is located in it's own iframe and if the banner receives focus somehow by a user clicking on it etc... the function keys will still be triggered. I attemped to prevent this from the settings.js file but was unsuccessful. As a user this should rarely occur but If you need to you can include the following in your banner html file.
The default banner file is /www/yourinstance/htdocs/profoundui/userdata/html/atrium_banner.html
Add the following code within the <head></head> tags. Also, you may need to clear your browser cache after editing the banner. This may pose a problem for users that have it cached as well.
In conclusion, I was rather surprised that the web browser allowed me to override these function keys but i hope this will help someone.
This is intended to disable all function keys when not inside an application that was launched from atrium and has only been tested in ProfoundUI v5.6 and Chrome v54.0.2840.99
In the atrium javascript extension located on the IFS at '/www/yourinstance/htdocs/profoundui/userdata/extension/atrium/settings.js' depending on your instance name.
Note: i believe the settings.js file needs to be created if it doesn't already exist. More info here: http://www.profoundlogic.com/docs/displ ... ecific+API
This is a function you can add to the atrium onload event to stop the function keys. If you're not already familiar with the settings.js extention of atrium you will only need to create the file and include this code. Otherwise just add the function and function call to the onload event.
Code: Select all
Atrium.onload = function() {
disableFunctionKeys();
}
function disableFunctionKeys(){
document.addEventListener("keydown",function(){
var code = (event.keyCode ? event.keyCode : event.which);
if(code >= 112 && code <= 123){
event.preventDefault();
event.keyCode = 0;
}
});
}
The default banner file is /www/yourinstance/htdocs/profoundui/userdata/html/atrium_banner.html
Add the following code within the <head></head> tags. Also, you may need to clear your browser cache after editing the banner. This may pose a problem for users that have it cached as well.
Code: Select all
<script type="text/javascript">
//disable function keys
window.onload = function() {
document.addEventListener("keydown",function(){
var code = (event.keyCode ? event.keyCode : event.which);
if(code >= 112 && code <= 123){
event.preventDefault();
event.keyCode = 0;
}
});
};
</script>
Last edited by shuffman on Wed Nov 16, 2016 12:41 am, edited 1 time in total.
-
- Experienced User
- Posts: 2711
- Joined: Wed Aug 01, 2012 8:58 am
- First Name: Scott
- Last Name: Klement
- Company Name: Profound Logic
- City: Milwaukee
- State / Province: Wisconsin
Re: Block Browser Refresh
Sam, thanks for the example.
I have two minor suggestions that you might consider:
1) Instead of naming the file "settings.js", I would consider calling it disableFunctionKeys.js (in the same directory). Using a name like that is a bit tidier, imho. Use settings.js for actual configuration options.
(Atrium will load any file in the extension/atrium directory, no matter what the name, as long as it ends in .js)
2) For your banner, why not link in the same file instead of repeating the code? You'd have to make some small changes so that Atrium.onload doesn't try to run when the Atrium APIs aren't there, but that's not hard to do.
I have two minor suggestions that you might consider:
1) Instead of naming the file "settings.js", I would consider calling it disableFunctionKeys.js (in the same directory). Using a name like that is a bit tidier, imho. Use settings.js for actual configuration options.
(Atrium will load any file in the extension/atrium directory, no matter what the name, as long as it ends in .js)
2) For your banner, why not link in the same file instead of repeating the code? You'd have to make some small changes so that Atrium.onload doesn't try to run when the Atrium APIs aren't there, but that's not hard to do.
-
- Profound User
- Posts: 22
- Joined: Fri Jan 29, 2016 11:15 am
- First Name: sam
- Last Name: huffman
- Company Name: gmdsolutions
- Phone: 7122624520
- Address 1: 2311 W 18th ST
- City: Spencer
- State / Province: Iowa
- Zip / Postal Code: 51301
- Country: United States
- Contact:
Re: Block Browser Refresh
Yes, that would be much cleaner.
So perhaps this would go in /www/yourinstance/htdocs/profoundui/userdata/extension/atrium/disableFunctionKeys.js
and this in /www/yourinstance/htdocs/profoundui/userdata/html/atrium_banner.html
Thanks, this is much better. except now i'll need to go back and organize some of the other functions i should have done this way. :-S
So perhaps this would go in /www/yourinstance/htdocs/profoundui/userdata/extension/atrium/disableFunctionKeys.js
Code: Select all
window.addEventListener("load", function(){
disableFunctionKeys();
});
function disableFunctionKeys(){
document.addEventListener("keydown",function(){
var code = (event.keyCode ? event.keyCode : event.which);
if(code >= 112 && code <= 123){
event.preventDefault();
event.keyCode = 0;
}
});
}
Code: Select all
<script type="text/javascript" src="/profoundui/userdata/extension/atrium/disableFunctionKeys.js"></script>
-
- Profound User
- Posts: 38
- Joined: Wed Jul 19, 2017 4:54 am
- First Name: Nadine
- Last Name: Gauthier
- Company Name: CAPL
- Country: France
- Contact:
Re: Block Browser Refresh
Hi,
I set up this code and it does not work on the atrium home tab if i clik inside.
Do you know why ?
Thanks for yours replys
I set up this code and it does not work on the atrium home tab if i clik inside.
Do you know why ?
Thanks for yours replys
-
- Profound User
- Posts: 22
- Joined: Fri Jan 29, 2016 11:15 am
- First Name: sam
- Last Name: huffman
- Company Name: gmdsolutions
- Phone: 7122624520
- Address 1: 2311 W 18th ST
- City: Spencer
- State / Province: Iowa
- Zip / Postal Code: 51301
- Country: United States
- Contact:
Re: Block Browser Refresh
It is because the homepage is a separate iframe.
Something like this might work. Note that i changed disableFunctionKeys() to have the document object be passed as a parameter.
The 3000 on the timeout allows 3 seconds for everything to load before trying to do anything.
if you replace the function you would also have to replace:
with:
The finished product would be a js file in /www/yourinstance/htdocs/profoundui/userdata/extension/atrium with this in it:
minimally tested with PUI 5.6.0 and Google Chrome
I thought of one other thing. If the homepage is coming from a different domain it probably will not let you attach events to it.
Something like this might work. Note that i changed disableFunctionKeys() to have the document object be passed as a parameter.
The 3000 on the timeout allows 3 seconds for everything to load before trying to do anything.
Code: Select all
setTimeout(function(){
var centerPanel = document.getElementById("Atrium-centerPanel");
var frames = centerPanel.getElementsByTagName("IFRAME");
for (var loopy = 0; loopy < frames.length; loopy++) {
var currentFrame = frames[loopy];
disableFunctionKeys(currentFrame.contentDocument);
}
},3000);
Code: Select all
function disableFunctionKeys(theDocument){
theDocument.addEventListener("keydown",function(event){
var code = (event.keyCode ? event.keyCode : event.which);
if(code >= 112 && code <= 123){
event.preventDefault();
event.keyCode = 0;
}
});
}
Code: Select all
window.addEventListener("load", function(){
disableFunctionKeys();
});
Code: Select all
window.addEventListener("load", function(){
disableFunctionKeys(document);
});
Code: Select all
setTimeout(function(){
var centerPanel = document.getElementById("Atrium-centerPanel");
var frames = centerPanel.getElementsByTagName("IFRAME");
for (var loopy = 0; loopy < frames.length; loopy++) {
var currentFrame = frames[loopy];
disableFunctionKeys(currentFrame.contentDocument);
}
},3000);
function disableFunctionKeys(theDocument){
theDocument.addEventListener("keydown",function(event){
var code = (event.keyCode ? event.keyCode : event.which);
if(code >= 112 && code <= 123){
event.preventDefault();
event.keyCode = 0;
}
});
}
window.addEventListener("load", function(){
disableFunctionKeys(document);
});
I thought of one other thing. If the homepage is coming from a different domain it probably will not let you attach events to it.
-
- Experienced User
- Posts: 2711
- Joined: Wed Aug 01, 2012 8:58 am
- First Name: Scott
- Last Name: Klement
- Company Name: Profound Logic
- City: Milwaukee
- State / Province: Wisconsin
Re: Block Browser Refresh
Assuming that the home page is a page that you can change, you could add code into the home page itself to block the F5 key.
Alternately, you could use Sam's solution, with the caveat that it won't work for the first 3 seconds ;-) And, as he mentioned, you will only have permission to change that child page from an Atrium extension file if it's from the same domain. If from a different one, the browser will block access to attach events to it.
Alternately, you could use Sam's solution, with the caveat that it won't work for the first 3 seconds ;-) And, as he mentioned, you will only have permission to change that child page from an Atrium extension file if it's from the same domain. If from a different one, the browser will block access to attach events to it.
-
- Profound User
- Posts: 38
- Joined: Wed Jul 19, 2017 4:54 am
- First Name: Nadine
- Last Name: Gauthier
- Company Name: CAPL
- Country: France
- Contact:
Re: Block Browser Refresh
Hi,
I added in my custom page that ...
and it works well !!!
I added in my custom page that ...
Code: Select all
<script type="text/javascript" src="/profoundui/userdata/extension/atrium/disableFunctionKeys.js"></script>
Who is online
Users browsing this forum: No registered users and 0 guests