detect browser refresh/F5/right click reload in angular 5 [closed] - javascript

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I have a requirement where, Users inputs something and submit then angular does a service call which returns if users input is valid/invalid. If valid take user to success page, if service returns invalid/bad input then user needs to be taken to failure page and should never be able to go back(using back button) or user refresh the page, user should still be on same page. Only option provided to the user should be close browser, there by not allowing using to submit one more request(leading to service call).

You cannot prevent the user from not running or editing client-side JavaScript code. Since this is a security requirement against the interest of that particular user, the solution must be server-side:
On the server, after getting the wrong answer, mark the user's profile as such. You may need an additional table in your database joining users and questions for that.
Whenever the user loads the question or submits it, first check the user's flag. If it's set, error out immediately.
Note that this behavior is quite hostile to the user. For instance, the user may accidentally touch Enter too soon, and will be shut out by your system.

Related

Is it possible to restrict user from to bookmark a specific web page? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I am developing a webpage with Python(Django) and want to restrict users from to be able to bookmark a specific web page. Is there a solution?
Bookmarks are Browser specific and you cannot intervene with what the user can do with the browser outside of your web application.
If you do not want the user to access the webpage directly, you can implement Authorization with Session IDs to prevent direct access to the specific webpage.
The answer is no, the user can always bookmark a page because it is a browser function.
But you can use sessions. Then make sure that any page request must have an active session ID, otherwise, it will return an error or redirect to the home page.
The user can add a bookmark to the page, but the bookmarks will only work for limited time. He won't able to access the page after the session timeout. This also has the added benefit of making the site impossible to index by the search engines.

How to make the search function on a website [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I was just wondering how do I make my website preview some info after the user searches for something stored in the database.
Basic approach for previewing user names as you type in a search bar. For this to work, you will need to use AJAX to query the server and also display the result as a preview for the user to click on if they want, without having to refresh the page.
User types 'Joe' into the search bar
The onChange() even is fired and you query your server with that the user has written "Joe". Keep in mind this query is via AJAX, so as not to force the page to reload.
Server side, you do a MySQL lookup of the table users, where the name is something like "Joe". SELECT NAME FROM USERS WHERE NAME LIKE '%what_you_sent_on_AJAX_request%' LIMIT 10;
The browser receives the response from the AJAX request and displays a nice dropdown with the output of the server. When the user actually click son this "previews" it is in that moment that you would actually reload to the page or take the user to a new page based on what they have clicked on.
That's a very basic approach for it.

Prevent a user from exiting from firefox using js [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
how can I prevent user exit firefox?
I want that user woldn`t leave page before all required fields are filled.
I would be happy to see full example...
Thanks
You can't stop someone from closing the browser, or navigating away from the page, if that's what they want to do. It's their browser - you can't force them to do anything.
That said, you can pop up a message by hooking the onbeforeunload event and returning a string if there are still actions you want them to perform. Most browsers will then display this string in a dialog asking whether they really do want to navigate away (or close the browser etc), however the Firefox devs have taken the stance that that is a security risk and will only present a generic message instead. Even with this in place, the user can still choose to close the browser or navigate away.

Program to repeatedly get the contents of a webpage [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I wish to get the contents of a web page that requires me to be logged in (and one that I do not have control over: e.g. Twitter or Facebook), for example I can have Chrome running and I can see Ajax updating the page updating, but I want to periodically get the contents of this page and somehow save it. I don't mind leaving a computer running to achieve this...
You can use any http software to achieve this (like curl). Depending on the site it will take some investigation of how requests are made, in what order, the post data, the encryption, the user agent, cookies, headers, etc. etc.
It could take some time to find the right recipe.
Generally these sites don't want you to do this though, so don't be surprised when you run up against captcha or other clever methods from preventing exactly what you're trying to do.
Chances are, if you have to ask, you won't get in. But have fun.

Calling form from another website [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I currently have a form which lets the user input 4 fields. What i'd like to know is if it possible to fill and submit a form on a totally separate website with the data that the user previously submitted using the form. If so, how can i do it?
It's possible with direct HTTP post or get requests if the form doesn't have a security mechanism like CSRF tokens. Browsers won't allow users to do that with AJAX if the target website doesn't allow it (Target website is supposed to set a specific header to indicate whether the cross domain requests via AJAX is allowed).
If you want to submit it as soon as the user submits it, just recreate the form with html anywhere you want with the fields. The target url should be the absolute URL.
If you want to submit it later, You can save the submission data in a database and use "cURL" to submit it later with PHP. (more details here)

Categories