Home Tutorials Forums Articles Blogs Movies Library Employment Press

Go Back   ActionScript.org Forums > ActionScript Forums Group > ActionScript 2.0

Reply
 
Thread Tools Rate Thread Display Modes
Old 07-03-2012, 03:06 PM   #1
wfz
Senior Member
 
Join Date: Feb 2008
Posts: 134
Default Disable F5 refresh

I have a quiz created in Flash. It works but if a user press F5 key to refresh the IE browswer window, Flash runs again and all the data would be lost and the person can retake the quiz if failed the first time.

I found some Javascript to disable F5 for Internet Explorer. They works fine without Flash. Once Flash is added, the Flash window still gets refresehd.

Are there codes you can use inside Flash to disable refresh window?

Thanks,
wfz is offline   Reply With Quote
Old 07-03-2012, 07:48 PM   #2
Prid
Prid - Outing
 
Prid's Avatar
 
Join Date: Oct 2009
Location: Halden, Norway
Posts: 1,157
Send a message via MSN to Prid Send a message via Skype™ to Prid
Default

I don't think that's possible! Could you explain your problem a bit better, maybe there's another solution for it. You could use SharedObjects...
__________________
17 Years old boy, who loves the Computer Technology
Prid is offline   Reply With Quote
Old 07-05-2012, 01:13 PM   #3
wfz
Senior Member
 
Join Date: Feb 2008
Posts: 134
Default

Prid, thanks for your suggestion.
The quiz does random select and initialize all variables when loaded the first time. After finishing the quiz and see the results, a user can refresh the page and the quiz would restart like new. A user can potentially check to find all the answers by refresh window a couple of times and pass it.

Your suggestion may work. Write data to LSO to notify that the quiz has started. The program would only reset everything if there is no data found. If found, no change. Then refresh does not do anything. One thing I'm not sure: Will all the variable values still be intact after a Flash file is reloaded? Another approach is to have a separate page with a new Flash to hold the score. So even if a user refresh, the quiz won't restart.

It would be easier if disabling refresh is achievable.

Thanks again for any suggestions,
wfz is offline   Reply With Quote
Old 07-05-2012, 02:09 PM   #4
MAGG0T
Member
 
Join Date: Mar 2012
Posts: 64
Default

I Don't know if that's possible for all browsers but you would need some script Rather than just actionscript, my guess is both you would need.
Something like
Code:
<html>
<head>
<script type="text/javascript">
window.onkeydown=function(e) {
               if (e.keyCode === 116 ) {
                       alert("F5 Has been Disabled");
                       e.keyCode = 0;
                       e.returnValue = false;                  
                       return false;
                   }

               }
</script>
</head>
<body>
<p> F5 disable IE</p>
</body>
</html>
Like i said i dont know if that would work for all browsers.
Also this code stop's a person from pressing Back to try and restart the quiz.
code Works in CHROME
P.s Hey Prid lol.

Last edited by MAGG0T; 07-05-2012 at 02:29 PM.
MAGG0T is offline   Reply With Quote
Old 07-05-2012, 02:39 PM   #5
MAGG0T
Member
 
Join Date: Mar 2012
Posts: 64
Default

Ignore my 1st post and follow this iv got it working in Firefox IE and Chrome
Step 1) 1st Download this .JS i made.
http://sound4-ls.webs.com/disable.js
Save the file and upload it to your web server.

Step 2) Add the Html into the page with the Quiz
Code:
<script src="/disable.js" type="text/javascript"></script>
Make sure the path to the Disable.js is right.

Step 3) Enjoy your disable action.

Example of it working here : http://sound4-ls.webs.com/disable.htm

May i also suggest opening the Quiz in a custom window that doesn't have a back button.
Let me know if it works and if you have any problems.



This is the .JS script you need to place it in a .JS file.

document.onkeydown=function(e) {
var event = window.event || e;
if (event.keyCode == 116) {
event.keyCode = 0;
alert("F5 has been disabled to prevent cheating");
return false;
}
}

If you cannot download it from my server try this download link http://www.MegaShare.com/4366124

Last edited by MAGG0T; 07-05-2012 at 07:02 PM.
MAGG0T is offline   Reply With Quote
Old 07-06-2012, 09:43 PM   #6
wfz
Senior Member
 
Join Date: Feb 2008
Posts: 134
Default

MAGG0T, thanks for you code. I tried it with my file but it does not work consistently. If you press F5 multiple times, 95% of the time, the Flash file gets refreshed.
I wonder if ActionScript can detect F5 keys press and stop itself from refreshing?

If nothing else works, I may just break the file into 2 files (1 with questions, 1 with result). Once the result is shown, refresh won't refresh the quiz.

Last edited by wfz; 07-09-2012 at 12:10 PM.
wfz is offline   Reply With Quote
Old 07-08-2012, 02:33 AM   #7
Prid
Prid - Outing
 
Prid's Avatar
 
Join Date: Oct 2009
Location: Halden, Norway
Posts: 1,157
Send a message via MSN to Prid Send a message via Skype™ to Prid
Default

I still believe that there's no workaround for this, as it's the browser which is behaving like this, and hi, MAGG0T
__________________
17 Years old boy, who loves the Computer Technology
Prid is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


All times are GMT. The time now is 07:03 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.