I am working on a single page application using angularJS which will work on Intranet. One of the requirement is after every 15 min i have to forcefully show a message to the user even if it he is working on some other program and once he click on OK button automatically that browser tab need to be shown.
this functionality need to work on IE11/IE Edge/Chrome/Mozilla firefox.
when i tried Javascript alert box with chrome it works as expected but when i tried it with firefox and IE it highlight the tab. unless user goes to that tab alert box doesn't shown up.
Is there any workaround for this?
Is there any other good solution?
I have priority for IE/Edge.
Thanks in advance.
I haven't really messed with AngularJS, but if it's just JS it should take normal JS. This code seems to work for me and I tested it and it worked for me (having it set to 1 second). The first block is the function to allow it to repeat, and the second block allows the code to initialize the loop.
function alertBoxTimer(){
window.setTimeout(function() {
alert('message goes here');
alertBoxTimer();
}, 900000); //60*1000*15 = 900000 = 15mins
}
//initialize alert
alertBoxTimer();
Related
I have a realy confusing problem with IE 11.
I use AngularJS to fill an element and display the element afterwards.
It works perfectly in FireFox and Google Chrome. In IE11 it wouldn't show until I click somewhere. It doesn't matter where I click. It could be somewhere on the page itself or my windows taskbar or on my second monitor.
I don't get any javascript errors on the console. After the random click IE shows at first only blank HTML. The styling is applied a moment later.
EDIT:
My Porblem is super strange. I've never seen something like this bug. My Code is running perfectly. All elements are thier with right values at the right place. All CSS rules should be applied. The pagination shows only after a completly random click somewhere but this only happens in IE11. Every other browser works like a charm.
Have any body saw this before?
I've asked two ather web devellopers in my company and we did code reviews but can't find any bugs in the code.
We think it's an IE11 bug. But there seems to be no one that can confirm this.
Try using $scope.apply and surround your scope change statements with $scope.apply.
$scope.$on("showPaging", function(){
$scope.apply(function() {
$scope.showPaging = true;
}
});
The use of $scope.apply is not encouraged though.
I am working on a website.
I have created a textbox, in which if I enter something, character count will be calculated via Jquery and get displayed in place of default character count.
I as soon as I click inside textbox everything on page kind of flickrs, No Idea why this is happening.
Many of you said, you are not able to reproduce it in your system. So I created a demo video
https://youtu.be/dRPXEA2MXGo
Got it [resolved].
Actually some chrome extension of mine was causing this. In incognito its working perfectly fine. Don't know what extension.
I've got a very basic HTML page, which only has to show a javascript alert.
I hear the sound that it's supposed to make when it pops up, but it's not popping up! I don't see it anywhere (in google chrome it does pop up). I also can continue working on my page without clicking "ok" on the (invisible) alert box, so that means that it really isn't there!
Any clues on how to solve this? I already rebooted my pc and disconnect my multiple monitors.
<script>
alert('SHOW!!');
</script>
More info:
My IE version is IE11
The popup did work properly before, without making changes to IE
On other websites, the popup isn't showing aswell
I did reset my IE properties (to factory default), no result
unable to test on older versions
Javascript is enabled
UPDATE: there is something going on with the page I am trying to have the onbeforeunload work on. I set it up in the layout and it pops up for every page besides that one... So there has to be some broken javascript, or a javascript file that redefines onbeforeunload. Since it can only be defined once
I am working on a Rails project and I am setting up a pop up to alert the user that their data will be lost if they leave the page without saving. So I am using window.onbeforeunload
I set it up on one page by adding this script code to the top of the view file
var saving = false;
window.onbeforeunload = function(){
if(!saving)
return 'Are you sure you don\'t want to save before you leave?';
};
where saving is set to true if the user hits the save button, which redirects them to a separate page.
The problem is coming up when I try to set up the EXACT same thing on a separate view file, that also needs the same functionality.
Except when I drop the code above into the file no pop up is given, at all... at any point. So then I looked around at other available options to set up the onbeforeunload function.
So I currently have it set up as:
var saving = false;
window.onbeforeunload = displayConfirm();
function displayConfirm(){
if(!saving){
if(confirm('If you leave without saving, your changes will be lost. Press cancel to go back to save')){
confirmExit();
}
}
}
on the second page. My issue is the pop up here doesn't work the same as the first implementation. Even weirder, the pop up shows up on window load... NOT before window unload.
I have been looking around and messing around with this for a few hours now. I am starting to get really irritated since this should have been an easy addition. Seeing as how it is already set up on a separate page, and working correctly. Any insight onto what maybe going wrong, or if I am making a stupid mistake, would be greatly appreciated.
Thanks,
-Alan
1) window.onbeforeunload = displayConfirm(); -- you're firing the function, instead of assigning it
2) onbeforeunload is great, but it's unsupported in a lot of ways. Some browsers don't even have it, period (all but the most recent Opera, for example), so if you're doing this for a wide audience, or you need it to work 100% cross-browser, onbeforeunload is sadly not enough on its own.
Try with
window.onbeforeunload = displayConfirm;
You are actually calling the function right away and assigning the return value of displayConfirm() to window.onbeforeunload.
Update
But you are limited to exactly one return statement in your onbeforeunload-function, see here. So calling "confirm" or some other custom function does not work.
Recently i was working on a project using this event, so i did do some search on the net.
There are few thing need to be taken into consideration when using the onbeforeunload event.
It is not supported by all browser. Opera, especially older version.
Some support it partially, such as not firing when refresh button is pressed.
Using this event will cause the page will not be cached.
Here is an article that is more thorough about the onbeforeonload event by Patrick Hunlock.
Basically, I would like to wait for the IE save dialog box to open up, and then run the next line of JavaScript.
Something like:
`window.open(URL,"_self",...);`
window.alert("save dialog started");
Can this be done? Thanks
Grae
I came up with this:
var iframe = document.getElementById("dFrameID");
if(iframe.readyState=='complete')
window.close();
else
wait and call this again.
Seems to work fine.
This is IE solution only. Good luck with FF.
Javascript and the browser do not interact on this level.
I haven't tested this, but you may be able to use setTimeout(...) to get there. I have used it (only in IE) to wait until a print preview dialog had been closed.
The trick would be to wait in a loop (say five times) with enough time between those five loops to guarantee that the save dialog would have appeared. Once the dialog appears, all javascript processing should freeze. Then, when the box is closed, the javascript would start up again, and your setTimeout handler would execute.
Again, I have no idea whether this will actually work, and it would probably be different based on the browser you're using. It is also complicated by the likelyhood that your download window and alert window would be separate.