IOS navigator.standalone mode open browser with submit button - javascript

I got a HTML page with a form. When I post, it returns a pdf based on the form data.
Is it possible to open the browser when submiting (post) the data when the user are in standalone mode?
I tried to set target="_blank" in both the form tag and on the submit button but it doesn't work.
It's not any problem if it's an a-tag link. But the problem with a link is that my form doesn't get posted (I know that I can post it trough JS but it will still be in the app).
If it isn't possible to post it with a submit button. I'll need to use a link (or another element) and with Javascript make an event that builds me the URL with a querystring with the form data. And that opens the browser and that will return me the pdf.
(However the main problem is that it isn't no way back to the app when the server give the user a pdf in app-view (standalone). And that problem isn't it any solution for what I can find. That's the reason to why I need to open it in the browser.)

Related

Download file with native JavaScript from a url

I have a react application where I am getting list of events and displaying them in a list. I want to have a button when I click on a specific event, it adds the user as an attendee. I had it that I display a button afterwards to show "download invitation link" but the requirement changed to download the file automatically once the user clicks the first registration link.
I am checking resources on the internet and found 2 options, the first is with URL.createObjectURL() but I don't currently have an object, I have a url of the file returned from the request. The second object I found was the browser.downloads.download but I am not sure if this would support internet explorer 11.
I thought about using the link I already have to download the file, and call it from another button, but I don't know if that's possible in React.
How can I solve this?

Auto reload POST request on browser back button

We have a web application developed on Spring MVC and Thymeleaf, where user lands on home page with a GET request. On home page, user enters 2 parameters and make a POST request. On successful submission, a new page (lets call it page2) open which have link to let say www.stackoverflow.com. User click on the link and comes to stackoverflow page. Now if user click on browser back button, browser states that this action requires form re-submission. On click of refresh button of browser, a pop appears to confirm re-submission and confirming it successfully open page2.
The problem is client dont want to have this popup or message page, instead want to auto resubmit the page on browser back button. Since the page from where the browser back button is clicked is out of my control, please guide how this can be done.
Note - 2 parameter entered on home page(page1) is not related with any authentication or login process.
As described by CBroe PRG pattern is the correct solution. Adding this answer for those who are facing same problem.
Use this on top of php page
header_remove("Expires");
header_remove("Cache-Control");
header_remove("Pragma");
header_remove("Last-Modified");

Popup displaying on refresh

I have a form, with a code to show a popup when I press a create/edit link. Now when I do a page refresh, I get the following popup
I have managed to stop the popup from appearing when Retry is pressed, by handling it on the code behind of my aspx, but when Cancel is pressed, the page blinks (I guess it renders again?) and the popup is shown.
It doesn't go back to the server. It just goes to the javascript function that displays the popup, and shows it.
It should be noted at this point that this popup is just a <div> which can be shown or hidden.The default property of this <div> is hidden.
Please help me solve this issue and also explain why this is happening. I haven't been able to find anything on the internet explaining this issue.
When submitting a form, content may be sent with either POST or GET.
Sending with GET appends values to the address defining what webpage you are on. It could look like this:
www.domain.tld/page?value1=apple&value2=banana
Sending with POST sends the value in a hidden field that the server receives.
Clicking "Retry" will load the website with the information currently held within the POST field. Clicking cancel should display the address you are heading to without the POST content.
I hope this answers your question. If not, is there any way for you to show the piece of code that handles the POST data?
The browser saves the data in the form when you submit it, and when you refresh the page, the browser attempts to send this data again. The popup is a warning from the browser that this is about to happen, which is important since the form could be on a shopping site, so resending the data would result in accidentally buying the same things multiple times.
To fix this, you can redirect to another page once the form has been submitted, or you can add code to reset the form so the data won't be sent again.
We should follow a best practice to solve this problem. Better have a look at this. When you press the cancel button, it simply load the previous page and values will be persisted.
My understanding so far is that when you press the cancel button, the values for the page is taken from the browser's cache. I cleared the cache to test this theory. The cache isn't just storing the values of the page but also the last server response received. In my case, the last server response was to show the the popup by calling my javascript function, along with the required values, which is what it did.
Now my work around to it was to make the closing button as a server command as well, so that the final response would be to hide the popup.
Please do let me know if there is something wrong in this explanation.

Open redirect page in new tab and reopen in the same tab on multiple redirects Django

I am making a blog app in Django and I want to do the following things
When the user submits the preview button I want to open the partially completed blog in a new tab in the same window.
Secondly if the user does not close the tab and again presses preview button, I want to display the updated blog in the tab which was previously opened.
How can I do this?
Edit:
As told in the answer below I am trying to use this code snippet to open it in a new window, but this does not work
<script>
var current_link = $(location).attr('href');
$('.preview_button').onClick(function() {
window.open(current_link,'preview_tab');
});
</script>
Also I currently have 3 submit buttons and I want to provide this feature only for 1 submit button i.e. preview So I cannot directly do (#form).onSubmit. For the the other two buttons, one updates the content via Ajax and the other redirects to a new page.
Try using a Javascript onSubmit to open the appropriate preview page with window.open, passing a name as the second parameter. It does almost exactly that. (If you want to support having different preview tabs associated with different editing tabs, include something in the name based on a tab ID of some kind -- maybe the article ID plus a random number, or something.)
You'll have to also send the updated content into the server via AJAX.

How to redirect inside jquery tab using javascript?

I've just got this jquery form working, it's based inside a jquery tab, and on clicking the submit button, it submits to a mySQL database without leaving the page or anything. Now, though, I want it to redirect the user, without making them leave the tab, to a different page inside the same tab once they've submitted their details.
Does anyone know the Javascript code to do this?
Thanks!
If you're trying to load a new page into the DIV where your form was, simply call
$('#idOfDivWithForm').load('newpage.php');

Categories