I have a js script code and I want to use only, when user press the back button on browser (load js script on the new page).
Is it possible?
You can't use the browser buttons to trigger any event on the page, so what you're trying to do doesn't seem to be possible.
Related
My website has button A. When I click it a pop up div appears with yes no option. I must click yes. So I write a script so that when I click button A, the yes option is automatically clicked. It goes like this
buttonA.onclick = function(){
document.getElementById('buttonYes').click()
};
I load this into Tampermonkey. When the page loads, the code work for the first time. After that the button goes back to their original behavior. The Javascript somehome only works once when the page is newly loaded. Can someone suggest a way to make the code works all the time in the page and I don't need to reload the page for it to work.
I am trying to disable the browser back button via JS code and have already seen lot of answers like
How can I stop the browser back button using JavaScript?
and
Trying to disable the browser's back button
But my problem is unique, The issue is that once my page is loaded and I don't click inside the document (Anywhere on the page) my browser back button still function the way it use to.
But If I click inside the document/page, all the above scripts and code works properly.
So the I want to ask that if there is any way I can make the document(page) active somehow so that if the user click directly on back button without clicking inside the page, They should not go back.
In my site I have many href and button that relocate the page you are in. I thought that, since you can't modify the body of the alert created with onbeforeunload, I can make my own type but my questions are:
Can I intercept when the page is relocated inside my site without onBeforeUnload or onUnload?
Can I make a function wait until a button i pressed?
Is it possible to intercept some other changes of the browser page like if the user try to close it?
Is it possible to disable the entire page and leave only a toast be available?
I'm trying to create a Chrome extension that features a browser action and a popup. I need to refresh the content I serve in the popup every time the user opens it, but since the on clicked event will not fire if a popup is assigned to the browser action, I don't know how to trigger the logic to refresh the content.
I'm trying to do this in the background page, but I understand that that might not be the best way. Does anybody have an idea of how to approach this?
Thanks for any help.
The popup is created from scratch every time the user opens it, so any javascript file you include using a <script> tag will be executed. You can include any logic you need there.
In javascript, how can I detect when the browser brings up the open/save/cancel prompt when loading a file?
If possible, is it the same for all browsers?
I'm trying to fix a problem with users clicking a download button, being impatient and clicking it again, and again which is taxing our servers. I tried just hiding the button while the file is processed, but the icon will come back before the open/save/cancel prompt shows up.
The code goes something like this:
...
users clicks button,
button hides,
external process gets the file,
button appears ...
You can't.
How the browser deals with a requested resource - open it, start an external application, offer a "save" dialog - is outside of what you can control using JavaScript.
You can't! No way, that's it!