/    Sign up×
Community /Pin to ProfileBookmark

Can I disable the back button?

I have 2 frames on my page. Left one contains the navigation links, right one opens the different links in it. I have a compare button in the right frame that looks at how many checkboxes are checked off and then goes to an appropriate link. If I opened a link already an then click back the checkboxes that I had already clicked on previously are still checked and if I try to uncheck them and check some other ones it does not open the correct link. So I was just wondering is there a way to disable the back button, so that the only way the user can get back to the previous page is by clicking the link on the left frame again? Or maybe there is a way to reset the checkboxes every time the page is loaded? Anyone know what’s the best way around this problem?

to post a comment
JavaScript

6 Comments(s)

Copy linkTweet thisAlerts:
@WebnerdJul 11.2005 — You can access the form of the left frame by using:

<i>
</i>window.frames[0].document.forms[0];



So

<i>
</i>&lt;script type="text/javascript"&gt;

window.onload=function(){
var coll=document.getElementsByTagName("A");
if(document.all){
coll[i].attachEvent("onmousedown",resetMain);
}else{
coll[i].addEventListener("mousedown",resetMain);
}
}

function resetMain(){
var mFrm=top.window.frames[0].document.forms[0];
for(i=0;i&lt;mFrm.elements.length;i++){
if(mFrm.elements[i].type.toLowerCase()=="checkbox"){
mFrm.elements[i].checked=false;
}
}
}
&lt;/script&gt;



Should reset the main form when any link on your right frame is "moused-down". This script goes in the right frame
Copy linkTweet thisAlerts:
@redakasashaauthorJul 11.2005 — Hey thanks for the help but in the code you provided it throws an error that i is not defined.

<i>
</i>
<i> </i>if(document.all){
<i> </i> coll[i].attachEvent("onmousedown",resetMain);
<i> </i>}else{
<i> </i> coll[i].addEventListener("mousedown",resetMain);



I tried creating it and setting it to zero just above the if statement(I don't know if that was the right thing to do or not) but it still does the same thing as before, the checkboxes do not reset whenever I come back to the page using a back button.
Copy linkTweet thisAlerts:
@felgallJul 11.2005 — You shouldn't use document.all to test for that since there are browsers other than IE that understand document.all for backwards compatibility which also understand event listeners. Try using an IE specific test instead.
Copy linkTweet thisAlerts:
@redakasashaauthorJul 11.2005 — What would be a specific IE test in this case?
Copy linkTweet thisAlerts:
@Willy_DuittJul 12.2005 — What would be a specific IE test in this case?[/QUOTE]

[b]document.uniqueID[/b]
Copy linkTweet thisAlerts:
@blah1985Jul 12.2005 — I don't think it's possible in Fx.
×

Success!

Help @redakasasha spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...