Safari Browser Back button issue - javascript

After logout browser should not allow to go back when user clicks on browser back button. This functionality is working fine in IE, FF but not working in Safari. Tryied a lot but not able to solve. Here is the code that i have used.
$(document).ready(function(){
window.location.hash="";
window.location.hash="";
window.onhashchange=function(){
window.location.hash="";
}
});

You can Disable safari browser back button if above trick is not working for you.
try this to disable back button-
function noBack(){window.history.forward();}
noBack();
window.onload=noBack;
window.onpageshow=function(evt){if(evt.persisted)noBack();}
window.onunload=function(){void(0);}

Related

iPad: document on click behaves differently on each browser

So I have an element and when I click on that, it will toggle open and close.
$(document).on("click","#element",function(){
doSomething();
});
So this was not working on an iPad and I searched for the issue on this forum and found different solution and most common one was to add touchstart. So I did that. My code is now:
$(document).on("click touchstart","#element",function(){
doSomething();
});
Now after adding this I am able to click on the iPad. But on desktop, it seems that it is clicking twice. So if I am clicking, it is opening and closing at the same time.
So I the added preventDefault function:
$(document).on("click touchstart","#element",function(e){
e.preventDefault();
doSomething();
});
Now, Chrome is working good on both iPad and Desktop. Mozilla is good on Desktop but Mozilla on the iPad is same, clicking twice effect.

Close current Tab using javascript for multiple browsers(Chrome,IE,Firefox)

I have Exit button in my page, when ever i clicked on that button,current browser tab should be closed.I wrote below code this is working in IE browser only but it needs to work in Chrome and Firefox.
Please help me.
Code:
window.top.close();
You can't do that in other browsers. If you check the console you will see:
Scripts may close only the windows that were opened by it

JQuery .ready when clicking browser back button - desktop browsers vs IPad browsers

I have this simple code on a page
$(document).ready(function () {
alert(“works”);
});
Then I go to the next page, I click in the browser back button and it doesn’t fire the $(document).ready, but if I return to previous page by a link it does.
Tested on desktop browsers and no problem but doesn’t work on Safari or Chrome on IPad
Any idea?
Thanks in advance

javascript and jquery not working on chrome android html5

I have a problem on Chrome on Android OS.
I work with a html5 page with jQuery and javaScript.
I have select box , number input .. etc.
When i try to "click", I have:
var hitEvent = 'ontouchstart' in document.documentElement ? 'touchstart' : 'click';
on a input or select nothing happens.
However when i do an alert("something") everything starts working.
On every browser works ok (Safari , Chrome on iPad,iPhone... ; Firefox , Internet Browser on Android) but not Chrome on Android.
Do you have any idea on how to solve this problem?
Normally when everything works after you put an alert,
that means there is a problem in a asynchronous call.
What is happening is that the alert is giving time for the page to really load or an event to actually happen. when you don't put an alert, an action is happening before the event
(for example an element is being called before it is generated)
Search in this perspective.
If it's working in Firefox, it is by pure luck from the way firefox is rendering the page, but still you have to fix your error.

Firefox This page is asking you to confirm that you want to leave

I have a script that if user is uploading file and try to close the browser it will trigger the onbeforeunload() and popup an alert.. I change the message but somehow it does not work in firefox, it works perfectly fine on IE or opera or safari.. the code is something like
window.onbeforeunload = checkUnload;
function checkUnload() {
if (document.upload.isEmailing())
return "Aaaa";
So, in IE and opera, when users close the browser during emailing, it will show pop up saying "AAAA" with leave or stay page button.
However, in firefox, it show
"This page is asking you to confirm that you want to leave - data you have entered may not be saved." with leave or stay page button.
Why it does not work, am I doing something wrong?
Note: FF I am using is the latest version if that will help.
For security reasons, Firefox now ignores the string you return.
There is nothing you can do about it.
According to MDN:
Note that in Firefox 4 and later the returned string is not displayed
to the user.
See the referenced bug for more info.

Categories