How to redirect user to the page they were just at without them noticing? - return

The website viewer would be at page A, click a link that sends then to page B, but I want them to return to page A without them noticing.
When they click the link it changes the layout the viewer is browsing the site with, so the redirection code shouldn't erase or undo the cookies or whatever are stored with the link click. Thanks!
Edit:
Here's what I'm doing. I have a page called setskin.php that has php code that takes header and footer codes for different layouts and applies them. I don't know how to show code without it going crazy, so there's a screenshot of it here:
http://figmint.uuuq.com/Picture%202.png
I want to change my website so that in a sidebar there will be the same setskin options (so it will be on every page). I was fiddling and managed to make it so when you click the link for the skin you want it changes the skin, but then you end up at the setskin.php page, which I don't want. I was looking for a way to make it so it sends you to the setskin.php page (since I couldn't see how to change that) and then back to where you came from.

You should use AJAX. That way you can do whatever processing is needed behind the scenes with zero impact on the user.

You can check the referer header and return to that. But if that isn't set go to a default page?
Other options include putting the previous url as a parameter, like a 'next' parameter. Then redirect to that after you're done. Quite common pattern used for login.

Related

How to change Google Sheet to "Viewing" while having "Editing" access?

For Gdocs, Edit access can be changed to Viewing to avoid unwanted changes.
How can that be done for Gsheets?
There's no button in the UI for it, but there is a "Preview" mode available for Google sheets. To get to it you need to edit the URL.
The URL of a sheet in normal editing mode ends with something like ...sOmE-lOnG-ID/edit#gid=1234567. Remove the /edit and everything after it, and replace it with /preview. Hit enter to refresh the page.
It will load a data-only view, no toolbars or anything. Useful to avoid making any changes, though unfortunately there's no commenting feature like Docs has.

In MVC, do I have to implement a custom error filter to redirect the user back from an error page?

For usability reasons, I have the requirement that an error page should tell the user something on the lines of
Sorry, we could not find this product in our database. You can go back to the previous page or search for a different product.
where the go back link is supposed to provide the same functionality as the back button.
I tried implementing it using Request.UrlReferrer, but it was a null in the smoke test. I found an answer here on SO which says that the browser can be set to not send it and
Bottom line is that you shouldn't trust it. Just append the url to the GET string and redirect based off that.
But as this view is displayed by using the default exception handling filter of MVC, I cannot append this in my code, as it does not send the user to the view in the first place.
Do I have to write my own exception handling filter if I want this functionallity, or is there a simpler way to do it? If I have to write it, what are pitfalls to look out for? It is possible that we will drop the link requirement if this means a substantial increase in the complexity of our code and just let the users click their own back button, but I don't have the experience to make an estimation.
I recommend solving this with JavaScript. Try
window.history.back()
As the onclick event for your anchor tag.

Url opens only on clicking link

Is there a way to ensure that a url successfully loads page only on clicking the link provided on a page and preventing url to open if the url is copy pasted in the browser address bar and Enter key is pressed ?
Edit
Session variables is the answer .. very silly question
You can't. Its a browser function and you don't have any control over it.
Users can't be outright prevented from this.
You can try to make it tough though, for example through hidden POST data or through a "proxy" link which acts as a gateway to your page. Session variables come to mind in this case, since you have effectively moved the locking logic server-side.

Jquery Mobile Logon Loop

Knocked-out a simple jQuery Mobile site with [logon -> index -> content] pages.
If I use the back button to the logon page, I can't escape no matter what I do - forward, back, filling it in, nothing.
I'd like to remove the #logon page from the navigation, so you cannot get back to it without typing it in, or logging out - any advice?
Easiest way to keep a page from showing up in history (with jquery mobile) is show that page in a dialog. This model works particularly well in situations where the content that would be in a dialog is either tangential to the main content or some sort of interrupt (which the login process is). See an example here. DISLAIMER: this is not the right way to implement content like this in the long run, it is only meant to show the effect of using a dialog in a login process to bypass insertion into history.
Another (more manual) route would be to use the a normal jqm page and do your login by way of an ajax posting. If the response came back as successful, then use location.replace() to remove the the current (logon) page from history.
I ended up removing the ajax navigation full stop and sticking to manual, not as pretty but headaches avoided!

How to have previous and next button in the django admin (change_form)

I want to modify the django admin for a particular model to provide the following behaviour.
A user make a search on the change_list page. The the user click a specific entry and he lands on the change_form for that entry. Nothing different to the usual.
Now, what I want is a mean to navigate the former search results. Basically next and previous buttons on the edit page.
What would be the best approach to implement this feature without modifying the admin site too much?
I will need to memorize the search in the user session, then when an entry is clicked I will need to known which place it has within the results to place my "cursor" accordingly. But I'm a bit in the cloud as the implementation side.
One way is to just put the next and previous button in the template for that particular model.
This can be implemented using simple javascript.
I ended writing a fully custom admin for that.

Resources