Fullscreen not working on Firefox 30 - javascript

When I am invoking fullscreen mode on Firefox 30 I am getting this error message on Firefox's console -
Request for full-screen was denied because Element.mozRequestFullScreen() was not called from inside a short running user-generated event handler. jquery.fullscreen.js:182
Everything working fine on Chrome.
I am using this approach for fullscreen : https://github.com/private-face/jquery.fullscreen

You have probably asked the browser to go on fullscreen directly from the code. It can only happen in an eventHandler called from an user action (like a click or keypress).This is what the user message is telling. As you can see, the eventHandler must run fast too. It must be under 1s.
It is for security reasons, so you cannot go fullscreen without requiring the user for confirmation.
Please see the note at MDN or the W3C specification.

There is an javascript confirm dialogue box in between the click of fullscreen button and $.fullscreen() in js side,
Solved the problem by skipping js alert on Firefox browsers.. Still thinking why it works fine on Chrome.

Related

Redirect to a new page using Browser or Tab Close Event in (Chrome, Firefox and IE) All of them

Please do not mark this as duplicate, as this is not being answered completely in any single post. also no recent working solution for latest browsers is found.
My Question is as under, i am using Asp.net C#, and the code should work on client-side preferably.
Is it Possible to Catch Browser/Tab Close Event for Non IE Browsers (ex. Chrome, Firefox) Current Versions [Version 81+ for Chrome (64-bit)], and Execute navigate to logout page.
The code which i tried for Chrome primarily is as below.
window.addEventListener('beforeunload', function (e) {
e.preventDefault();
e.returnValue = 'this is cuctom message';
window.location.href = "~/logout/Logout.aspx";
});
Now when i use above code in IE, it gives me message like
the problem which i am facing with above code is.
On Every link click this message is called in IE, along with tab close too, and i want to call this message only on tab or browser close.
for Chrome though, above code is called only on link navigation, but not redirected to logout page, and not on browser close.
I am stuck in this activity, with no way forward, can anyone please help me out with a way towards solution to this issue.

changing window.beforeunload message

I'm wondering if can I change the window.beforeunload message. All examples on the internet are similar to this:
$(window).bind('beforeunload', function() {
return 'You have unsaved changes. If you leave the page these changes will be lost.';
});
That's cool, and in Google Chrome my message will be displayed, but in Firefox the default message is displayed. How can i trick Firefox to display my message and not the default message?
onbeforeunload is a weird event. Browsers have been debating what to do with it for a while.
IE and Chrome will display your message in the dialog along with their own message.
Firefox used to display your message, but in version 4+, they stopped supporting custom messages. See this: https://bugzilla.mozilla.org/show_bug.cgi?id=588292
Opera doesn't even support the onbeforeunload method!
This method is under debate because it can be used for evil, and also because it can confuse/annoy users. Scammy, virus-laden sites can use messages like:
"Leaving the page will mean your computer may still be infected, please stay and install our virus scanner"
Nowadays, websites can use AJAX / localStorage to save changes, so this event isn't really needed.

IE9 Window Loses Focus due to jQuery Mobile

In our product, we're using the most recent development version of jQuery Mobile in our ASP.NET website. Each and every time we do an ASP.NET postback, the browser window goes to the back of the screen.
Example:
Maximize any window. Example: Visual
Studio, Word, Windows Explorer.
Maximize IE9 over it. IE9 is the only
thing you see on the screen.
Click on a button in our solution that does
a postback.
IE9 is no longer visible.
Whatever was behind it now has focus
(and fills the screen, as it is
maximized)
Only workarounds I know:
Don't include the jQuery mobile scripts.
Ensure IE9 is the only maximized window in Windows.
I don't know what jQuery Mobile is doing in the background and am assuming this is a bug in IE9 that will eventually be fixed. However, if you had any tips on how to prevent it from happening in the meantime, that would be great.
Edit: Seems it isn't on every postback. It is on every postback that performs a Response.Redirect. I should add that all my postback are actually utilizing ASP.NET AJAX, not full postbacks.
I know this is an old post, but for people coming here from Google:
I ran into this same issue today. It seems this lose focus behavior is what IE does when you trigger the blur event on the window object. This was the code that caused this issue for me:
$(document.activeElement).blur();
activeElement will default to the body element when there are no other elements in focus, and the blur event then bubbles up to the window. To fix this I simply did a check like:
if (document.activeElement != $('body')[0]) {
$(document.activeElement).blur();
}
I had similar problem with IE10 and jQuery 1.7.2.
I found these lines in my code:
$(document.activeElement).blur();
and
$(':focus').blur();
So, adding simple .not('body') resolves the problem:
$(document.activeElement).not('body').blur();
$(':focus').not('body').blur();
This same issue seems to occur with jQuery Mobile 1.4.2.
When using IE 10, with a single tab open and another window on the same monitor, if you open a popup it will send the browser to the background.
To fix this you have to edit the _handleDocumentFocusIn function. You need to change the line(10391) that reads:
target.blur();
to
if (targetElement.nodeName.toLowerCase() !== "body")
{
target.blur();
}
I made a pull request so hopefully this will be included in the next version.
Just posting this link to anybody who is experiencing more of this continued mess. I am seeing the problem on IE 9 and IE 10 on a window.location = 'BLAH', from within the Angular location resource.
This doesn't seem to solve the problem for me, but it may help others:
http://support.microsoft.com/kb/2600156/en-us

See what methods/events being called in JS

Got this page which has some javascript on it (very heavy) and I am trying to see what happens when I click a certain element. However looking at the code there is no onclick function - the javascript is several JS files so take far to long to browse.
Is there a way with Firefox (firebug), Chrome or even IE to view whats / log what is happening when I click on an element in the browser?
In firefox (and this is also available in chrome and IE in another form) install addon firebug (if not installed). Go to Tools->Birebug->Open Firebug. Click on Left Icon and ask for tracing.
You can then trace your program.
Another way is to cause a breakpoint when you start, and you manually follow the execution of the script.
Chrome Developer Tools shows all attached event handlers for an element. See the section on Event Listeners towards the end.
#wizzard, try this: firebug - profiling button
ff only, but there is a lite version for chrome for example

Strange behaviour opening pop-up window in Internet Explorer

I have the following JavaScript code to pop up a window in Internet Explorer. The code is executed from a page within a Microsoft CRM modal dialog box. (RequestID is a string that is always the same in the test system - at the moment it contains "abcdefg" - without the quotes).
var cancelUrl = "CancelRequest.aspx?RequestID=" + RequestID;
alert("About to open a window.\n\n" + cancelUrl);
window.open(cancelUrl);
alert("Window opened");
I expect to see a message telling me that I am about to open a window. I then expect to see a window open and get another message about the window having been opened. I don't really care about the order of the last two events; the alerts are there so I know the code has been executed.
I have two PCs and a virtual PC. All running IE7. On the Windows 2003 VPC, the messages and pop-up appear every time without fail.
On the Vista PC and WinXP PC, the messages appear but the pop-up only appears intermittently. (I think this may be the case on the Vista PC too).
All three have identical settings in IE. All have the IE pop-up blocker disabled and have no other pop-up blockers installed.
Can anyone shed any light on this?
Ah, I think I got it... missed it in the description...
You are trying to open a non-modal window from a modal dialog in IE.
This AFAIK, should not work.
Try opening another modal window instead.
Effectively you are saying...
on window A, open up modal window B, now open up non-modal window C, which isn't really valid.
This code is simple. Use debugger and see what is going on.
Check that site with FireFox or Chrome, they have JS debuggers.
Edit:
Add try/catch block around window.open() and see if there is some exception there.
Edit 2:
I see now that you are sending characters as RequestId. You should check if that URL can handle that kind of value. Since name is RequestId I'd say that there is big chance that there should be numeric only parameter. If that is correct, then it can happen that server side crashes when you try to open window and then nothing happens. Reason more to set try/catch block and test.
You might want to try Firebug lite, which will work for IE.
http://getfirebug.com/lite.html
The try/catch other people have mentioned is also a good idea. I think.
Additionally, is there any chance that the pop-up is trying to use a window that is already open but minimized. So it doesn't appear to be working but it's really just reloading the minimized window?

Categories

Resources