Click here to Skip to main content
15,882,209 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Dear Friends,

I have created a Online Exam Webpage.
Once the user select Start Exam, I am opening a New Window and displaying question and same time ill close the existing window.
But user opens new window and getting the answer from google.
I am alowing user to enter one word answer also.
So I cant block then from key press.

Can any suggest any idea for this issue.

Rajesh Kariyavula 2-Jun-12 3:33am    
I suppose that you to avoid copy & paste in your answer TextBox. Is it right?
Arunprasath Natarajan 2-Jun-12 5:41am    
I want user to write on the text box but I dont want user to open or use another window, when he is attending the exam
Arunprasath Natarajan 27-Jul-12 5:52am

1 solution

You could attach Javascript Blur event to the page body, and use it to send a cancel to the server.
That way, when ever the page looses the focus, you can cancel the exam.
One way to do this is like this:
<body onblur="javascript:window.opener='x';window.close();">
Which works in Chrome to close the window without prompting.
Share this answer
Arunprasath Natarajan 2-Jun-12 5:40am    
I have tried with this. But its not working.
OriginalGriff 2-Jun-12 5:47am    
Not a helpful response, I'm afraid!
Remember that we can't see your screen, access your HDD, or read your mind.
Arunprasath Natarajan 2-Jun-12 9:29am    
Sir, I want to close my exam window if user tries to open new window or any other action.
Arunprasath Natarajan 6-Jun-12 5:58am    
Sir, When user click on start exam button then I am opening the New Window. But when I focus on the same window its closes. Kindly suggest.
Arunprasath Natarajan 8-Jun-12 2:29am    
It works and thank you very much

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900