Google Docs, Gmail etc have this feature where if you try to leave a page that hasn't been saved it pops a dialog box with "confirm, Are you sure you want to navigate away from this page?"
Is there a JQUERY plugin that will allow me to implement this kind of functionality?
Thanks
You need to look at the window.onbeforeunload event, which is not supported in all browser, so don't count on it.
Here's the MS documentation for it - it was originally an IE only event.
window.onbeforeunload; it does appear that there are efforts to Standardize the event between browsers too: http://kenbrowning.blogspot.com/2009/01/using-jquery-to-standardize.html
I just found this which seems to be an elegant solution too: http://www.jonstjohn.com/node/23
Related
How is this site triggering its popup while bypassing Chrome's pop-up blocker?
http://undertexter.se/
I thought pop-up blockers only allowed window.open if it was triggered by a user action but that's not the case here so how are they doing it?
OUTDATED
Origin resources and fiddles do not work anymore.
I figured out that there is an popup opening in chrome if you visit the Website first time (empty cache) and click somewhere on the document.
After a refresh and a click on it again nothing will happen if cache wasn't removed.
So lets start the game of reverse engineering...
Took the script from
http://undertexter.se/ and startet refuscation.
After a few steps I got the following code and I think this is not planned by browser manufactures to support something like this.
Now I wish you a lot of luck to use that for your own but I think it's evil.
Look on js fiddle for the result:
Its the reverse of:
http://www.wigetmedia.com/tags/undertexter.se.js
http://jsfiddle.net/W9BdS/
Tested on my own server, This opens up http://google.com in a new (standalone) window in Chromium 28 on Ubuntu 12.04. Adblock is active.
<script type="text/javascript">
document.addEventListener('click', function() {
window.open('http://google.com','...','width=1080 height=640')
})
</script>
try this using JQuery
$('#yourCotrolId').on('click', function() {
window.open('yourLink','...','width=1080 height=640')
});
window.open is blocked by modern browsers when called not in a click event handler.
I faced this myself while using Rails' format.js responses and wrote a small plugin that makes showing JS popups as simple as calling window.open():
Popup("<div>Hello world</div>").show('up')
You could use the .trigger method for simulating an user action:
Click
$('a').trigger('click');
.trigger() can not be used to mimc such native browser events, you can use .simulate() from simulate.js to mimic such events.
include simulate.js in your file and use,
$('a').simulate('click');
My web application uses alert and confirm boxes to display information when a link is clicked.
All browsers display these boxes properly except for Chrome. When I click on a link in Chrome, all I get is the box displayed with one word "Javascript" inside.
It has to work correctly in all browsers, even if the box displayed is constructed a little different in each. It barely works in IE but it does work and if you are going to use that crippled excuse for a browser, you deserve it! ;)
I didn't think this simple problem required a demo in jsfiddle and every one knows what an alert or confirm box looks like, nevertheless if someone needs more clarification please don't just not answer at all, but let me know.
Thanks,
Paul
well alert box is a browser component, therefore all browser vendor uses their own implementation. Since you want same result on all browser, the best you can do is use your own code to produce the result like using modalpopup which will be static around all browser
If you want to ensure cross platform and cross browser compatibility i would use something like:
jQuery Dialogs
Would be alot handier and ensure it looks/works the same everywhere.
Please note jQuery is just an example and any other alert/confirm like JavaScript/CSS would do the job just don't rely on the browser!
Please also note that browsers can change there implementation at any time leaving you stuck if you dont use your own!
I need to disable fullscreen message ("you've gone fullscreen") coming on the top when chrome fullscreen mode is activated .
i need to do it through javascript . but it's one of the default functionality of chrome.
can any one help me out ?
It's not possible. As you pointed you it's one of the default functionality of chrome.
and I agree with the comment by mic You can't it's there for security
That message is, if you it can be disabled at all, likely a user preference. I have had my fair share of changing that kind of things for a custom "layer" over windows with an integrated browser and I can tell you it's impossible with javascript without some listener app. We created a C# listener app for that kind of thing that keeps checking a certain text file. We made javascript edit the text file and then let C# work it's hacking magic in some of the user's settings.
You could take a look at Chromium, the stripped down version of Chrome, if that would be of any help ;)
ps: To all the people going mental over changing user settings like that, our customers were old people that were unable to use a computer, and our application's purpose was to do as much as possible for them.
You cannot possibly do that as suggested by these links.
https://superuser.com/questions/398945/disable-the-youve-gone-full-screen-notification-in-chrome
https://groups.google.com/forum/#!topic/chromebook-central/h1crbhOy-7U
On the other note, why exactly would you want to do that?
I need to implement parent page redirection from iframe. I know that it is impossible to do in different domains due to browsers security.
However I found that links have target attribute and tried to use it in the following way:
someLink
It works fine if I click this link manually, but I couldn't find cross-browser solution to simulate it using JavaScript.
document.getElementById('testParentRedirect').click();
This works fine in IE, however Firefox and Safari don't know click function :).
I tried to work with jQuery, but for some reason they don't simulate click event for links.
(see following post)
I couldn't find any appropriate solution on Stack Overflow.
Maybe someone could help me in it. I will appreciate it. :)
You can do this in javascript to exit a frame:
window.top.location = "http://google.com";
You can try
top.location.replace( "http://google.com" );
in javascript to "escape" from the frame.
Edit: Using replace is slightly nicer, changed my answer to use that.
Using jQuery, is there a way to disable the click sound in IE that happens when you post?
The IE click sound is a feature of the browser that you can't control from JavaScript. The only way to disable it is in System Sounds in the Control Panel.
It may very well be possible using this solution: http://www.julienlecomte.net/blog/2007/11/30/
But in short, John is right about it being a browser sound not controlled by javascrÃpt or anyting else than a registry change, wich a website will not manage to do.
I know the above "trick" has worked before, so if nothing has changed it will still work.