Disable refresh icon of chrome - javascript

Can we disable the refresh icon of Chrome browser using jQuery/JavaScript? I was able to disable refresh using F5 but not using the refresh icon. Any help is appreciated.

Short answer: No.
Long answer: No, because allowing websites to disable browser controls could cause all sorts of bad consequences and allow hijacking the browser or holding it hostage. The best you can do is prompt the user and confirm their action, as indicated in this answer.
Also, FYI, it is a refresh button, not an icon.

You can't disable refresh action of a browser. It's impossible.
If you need to remember something important you can use COOKIES or LocalStorage|SessionStorage to save data.

To truly disable refresh you must use a server side script to check for page state changes
Try using a server-set cookie, such as PHP's $_SESSION, or even .Net's Response.Cookies, to maintain "where" your client is in your site.

Related

detect completely browser closed in JavaScript

I am working on a project using polymer 3 where I want to destroy/clear a cookie and log out the user from the website. Destroying or clearing cookie is not an issue but I am just not able to detect when the browser closes.
So far I have tried:
window.onbeforeunload
from the JavaScript end and for php have tried this:
session_set_cookie_params(0);
but none are working. Any help would be really appreciable.
I can use setInterval() or setTimeout() function but it's not fulfilling my requirement.
Plz don't suggest any jQuery suggestion.
Use sessionStorage. It Works propably exactly as you want. Whenever user close browser, everything in sessionStorage is removed. Be aware that it works only when user completely close browser. Not only a tab.
I would go the other way around. If the user arrives to the page for the first time, log out the user. You can easily do that by checking if a certain variable is set or not, and then set it whenever the user logs in.

Javascript disable switches current tab functionality in browser

Is there a way to accomplished this on browser?
Disable opening another web page
or disable switch current tab functionality in browser
when certain page (in this case my page) is still open?
I want to make a quiz in web, but i want to eliminated the posibility for user search on internet for the answer, but have no idea how to accomplished that.
plis give me a solution..
regards..
No, this isn't possible, for (what I hope are) obvious reasons.
This not possible.
Even if it was possible in theory, how would you stop the user opening another browser (different brand to the current one)?
How would you stop the user from using their mobile phone to search the web?
If this quiz is being run in a controlled environment (like a classroom) you could run the web browser in some sort of kiosk mode with strict policy setup against opening other tabs etc. But if it is being run in a classroom, then you already have someone supervising anyway. Why bother then

Link Button with No History

I am designing a website for a domestic violence agency and I want to include an "escape" button. However, simply having a link leaves a danger of someone looking in the browser's history or clicking the back button to see where they were.
So, my question is: (1) Is it possible to load webpages and exclude them from the history? (2) Is it possible to disable the back button after following a link to, say, Google?
Thanks in advance for any help!
For disabling the back button:
<script language="text/javascript">
function goNewWin() {
//***Get what is below onto one line***
window.open("backbuttonnewpage.html",'TheNewpop','toolbar=1,
location=1,directories=1,status=1,menubar=1,
scrollbars=1,resizable=1');
//***Get what is above onto one line***
self.close()
}
</script>
Click to go to a new page
from http://www.htmlgoodies.com/tutorials/buttons/article.php/3478911/backbutton.html
No.
However, you could detect the browser and then explain details on how to clear history/caches for their current browser.
Maybe and no. That is entirely browser driven. Some browsers have been known to replace pages in history when window.location.replace(newURL) is called, but that is not guaranteed and not recommended.
Concerning your first question: As far as I know, the browser's history is completely dependant only on the browser's settings. Websites cannot and (should not) try to access any of the browser's preferences and functionality . A website just provides information (i.e. code and resources) - it is the browser's task to decide what to do with it (how to parse and render it).
So in my opinion, the best you can do is to suggest the user to clean one's history or use a "private mode". You even might provide information about how to do that, depending on the user's browser.
In any case: All the best for your project against domestic violence!

How to open a new window (or in a tab), but not give it focus

I have a function that I want to open up a URL in a new tab on a click event, but not give that tab focus. Is this possible with javascript?
You can't steal focus from a newly opened window. It's a security feature preventing sites from "taking control" of your browser. That would be a browser configuration setting.
As far as "hiding" focus from a popup, you might be thinking of what's called "PopUnder". Basically you use window.open() and set the option _blank and the paramater alwaysLowered, but it will not work gracefully for an average website. It requires you to have a signed script and take advantage of the Netscape Security PrivilegeManager, like this:
netscape.security.PrivilegeManager.enablePrivilege("UniversalPreferencesRead UniversalBrowserAccess"); // etc...
Sorry bro :)
You can attempt to open a new window, then set focus back to the current window. However, user settings may make this impossible, or it might already be the default behaviour.
Pop–unders are used by some web sites probably to disassociate the web site from the window (i.e. so you don't know where it came frome). So they are assuming a certain naivety on behalf of the user. They are considered spam and treated with the same contempt.
If you outline what it is you are trying to achieve using a pop–under, you might get advice on better ways of doing it. Or not. :-)
To my knowledge it is impossible bro.Since the user's browser Settings will conflict with your logic

How do I know when the browser is being closed?

I am writing an ASP.NET application that tracks the user's scores and info (it is a
training application) to an access database, if any one closes the browser directly I want to display an alert message.
My problem is that I cannot use the unload event because When I pressed any ASP.NET button at that time unload event occurs. What event should I be using that will work for IE and FF?
I want to handle event Browser close(X).
The onbeforeunload event will only give you the confirm box with a message. You can't put more functionality into it.
What you should be doing is having both the window unload eventhandler and the logout button click eventhandler call the same logout method. You don't need to stop the user and ask them to press your button, your button should be just another way of doing the same thing.
Also: have you considered SCORM?
Not sure you know what you want to do here. ;-)
Do you want to prevent the user completely from closing the browser until a certain point in the trainig? If so, have you considered using a modal and maximized window? You should be able to maximize the window without the titlebar, buttons and menus.
Or if you just want to keep track of the progress, scores or similar, then you could use cookies handled by the browser via JavaScript. Just bear in mind that this will keep the data on just one machine for the student.
If you just want to warn the user that he is about to leave the training course, you could use onbeforeunload
I think others have adequately answered your specific question, but Tooney raises some good points. To expand on these. Where are you currently maintaining your the state? Are the scores stored in cookies, within a server-side session or do your persist them page by page within the database.
Assuming this isn't a cheap and cheerful solution, then I would suggest you consider persisting results page by page, as it is minimise the loss of information caused by a premature exit (either by design or accident). Of course, you then need a process to cleanup incomplete training session.
You could still use the onbeforeunload function to trap user exits, but personally I don't like UI's that double check users actions.
Good luck.

Categories

Resources