I have a application where i have disabled the back button of IE8 by using the following code.
window.history.forward();
function noBack() {
window.history.forward();
}
I know this code takes the page back and again moves the page forward. i have called a function onload of the page which makes a textbox read only. i have used the following code to make it read only.
$("#IDofTheTextBox").attr('readonly',true);
but if i select the textbox and try to edit by pressing "BackSpace" button, IE back button is getting invoked and the textbox which was readonly is not readonly anymore. Can anyone help me how to solve this issue?
I have a application where i have disabled the back button of IE8 by using the following code.
window.history.forward();
function noBack() {
window.history.forward();
}
I know this code takes the page back and again moves the page forward. i have called a function onload of the page which makes a textbox read only. i have used the following code to make it read only.
$("#IDofTheTextBox").attr('readonly',true);
but if i select the textbox and try to edit by pressing "BackSpace" button, IE back button is getting invoked and the textbox which was readonly is not readonly anymore. Can anyone help me how to solve this issue?
Share Improve this question asked Feb 23, 2013 at 6:54 Akshar A KAkshar A K 4125 gold badges15 silver badges24 bronze badges 10- 7 Why would you break the back button? It's horrible UX.. – MarcoK Commented Feb 23, 2013 at 6:55
-
1
Did you try setting the
readonly
property inside the HTML itself – Harsha Venkataramu Commented Feb 23, 2013 at 6:56 - 1 Have you considered the following. A person is looking at you web after looking at a previous web site. They want to go back to that web site and are unable to do so. So what do you think that they will reflect on your web site and pany? I, for one, would not visit your web site again and would go else web to do my business as I think this is poor form. – Ed Heal Commented Feb 23, 2013 at 7:06
- 1 twitter./codinghorror/status/133821946239516672 – Kyle Strand Commented Feb 23, 2013 at 8:16
- 2 I can think of no justifiable reason for a web page to break browser functionality. – Kyle Strand Commented Feb 23, 2013 at 8:17
3 Answers
Reset to default 4The answer is simply "NO"
If you're trying to prevent the user from losing their work, try something like:
window.onbeforeunload = function() { return "Are you sure want to leave this page?."; };
function changeHashOnLoad() {
window.location.href += "#";
setTimeout("changeHashAgain()", "50");
}
function changeHashAgain() {
window.location.href += "1";
}
var storedHash = window.location.hash;
window.setInterval(function () {
if (window.location.hash != storedHash) {
window.location.hash = storedHash;
}
}, 50);
You add the above javascript functions in the js file and onload call the function changeHashOnLoad().
its working fine in IE8. i just tested it.
I dont know what your page is trying to do... but this is what we do:
We have an assessment where we do not want the browser buttons enabled... because we run ajax/logic when the user hits next/back etc (to determine what to display next based on their inputs). Back and forward buttons can muddy that process up.
So..... we have users open our assessments in A NEW WINDOW so the back button is already disabled...(there is no prior history in a new window). Then, Our next/back buttons use window.location.replace(url); This will prevent a history item from being created. Therefore, the back/forward buttons are never enabled and they must use the next/prev buttons to navigate our tool.
I would not try to muck with the buttons outside of something like the example I provided.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745241181a4618190.html
评论列表(0条)