I am making an online examination website where in which the users can attend the examination. I want to get a notification when the user minimizes or closes the website or opens a new tab. Can anyone tell me how to do that using languages like html css js php jQuery sql.
-
1Do you want to do this in order to detect if the student is looking up the answers on the web? If so, it's not worth doing - they will just use another device, like a mobile phone. – halfer Feb 15 '15 at 14:58
-
actually its an intranet thing – jay Feb 15 '15 at 15:07
1 Answers
You may use Javascript Window Object Model
Example
Windows Closed Property: A function that checks whether a window called "myWindow" has been closed or not:
function checkWin() {
if (!myWindow) {
document.getElementById("msg").innerHTML = "'myWindow' has never been opened!";
} else {
if (myWindow.closed) {
document.getElementById("msg").innerHTML = "'myWindow' has been closed!";
} else {
document.getElementById("msg").innerHTML = "'myWindow' has not been closed!";
}
}
}
closed: Returns a Boolean value indicating whether a window has been closed or not
defaultStatus: Sets or returns the default text in the statusbar of a window
document: Returns the Document object for the window (See Document object)
frameElement: Returns the element in which the current window is inserted
frames: Returns all elements in the current window
history: Returns the History object for the window (See History object)
innerHeight: Returns the inner height of a window's content area
innerWidth: Returns the inner width of a window's content area
length: Returns the number of elements in the current window
location: Returns the Location object for the window (See Location object)
createPopup(): Creates a pop-up window
focus(): Sets focus to the current window
moveBy(): Moves a window relative to its current position
moveTo(): Moves a window to the specified position
open(): Opens a new browser window
print(): Prints the content of the current window
prompt(): Displays a dialog box that prompts the visitor for input
resizeBy(): Resizes the window by the specified pixels
resizeTo(): Resizes the window to the specified width and height
scroll(): Deprecated. This method has been replaced by the scrollTo() method.
scrollBy(): Scrolls the document by the specified number of pixels
scrollTo(): Scrolls the document to the specified coordinates
setInterval(): Calls a function or evaluates an expression at specified intervals (in milliseconds)
setTimeout(): Calls a function or evaluates an expression after a specified number of milliseconds
stop(): Stops the window from loading
For more: w3schools

- 5,216
- 1
- 33
- 39