refresh page after form download submit - html

I have a form that as an action returns a download. The problem is that the page will pop-out the download, and you can save it, but it will not allow another form submit.
i was thinking of doing a page refresh after the submit. But i cant figure out how to do that and not stop the download. Do you have any ideas.
Thanks

Make the initial form POST to an action which returns the same view along with some javascript that triggers the download. Also provide a "Your download should start shortly. Otherwise, click here"-link.
Have a look at
Auto start file download after form submission

This seams to be a bug in Chrome.
The solution i got from here was to open a window before submit and put the target of the form in that window.
function submitForm() {
//next line is the FIX
window.open('','google');
form = document.getElementById('myform');
form.action = "http://www.google.com/search";
form.target = 'google';
form.submit();
}

Related

How would I get a .pdf file to open after one dismisses an alert (HTML). (Note: the alert pops up after an ID and password have been entered)

I have done thorough research and couldn't find anything that doesn't involve clicking a button in the page and doesn't require a download of Adobe Acrobat.
After the alert() redirect the user to pdf url:
alert('This is the alert. Click OK to continue');
window.location.href = "http://the.url.to/file.pdf";
Alternatively if you want to open the pdf in new window/tab then:
alert('This is the alert. Click OK to continue');
window.open("http://the.url.to/file.pdf");

How to close a tab in from a chrome extension?

I wrote an exension which, when a website opens, fills some fields and presses the submit button.
I want to close the tab after that process.
I used the code below:
chrome.tabs.getCurrent(function(tab) {
chrome.tabs.remove(tab.id, function() { });
});
But it doesn't work.
Any suggestions?
What's happening after the submit button?
Do you send a message to the background?
Please note, you can close a tab from the background script.
You can call chrome.extension.sendMessage from a content to the background, receive tab object and call chrome.tabs.remove(tab.id);

Open Help web page from Google script HTMLservice interface

I want to put a Help button on an HTMLservice interface. I have tried it directly on the button and also by calling the function below
function helpClicked() {
document.getElementById('payment').value = "Help Clicked...";
window.open("www.google.com")
}
This changes the payment field to validate that the button was clicked but does not open a new browser window with the url. Is there any way to make this happen?
Use a link (a tag) directly with the correct URL instead of a button and use css to make it look like a button (if you need one). You can still hook triggers to the link, but you won't need to do the window.open yourself, therefore avoiding this problem/limitation.

php or other script to close browser session after html form submission

I recently implemented a .htpasswd based login page and am trying to figure out a certain way I have in mind to close the browser window (because that is how I can reset the authentication so the user cannot log in again).
My idea is that once the user logs in and submits the information on the form they have to fill out, the submission of the form would trigger a script to close the browser window in 5 seconds. The user would be warned before hand that this will happen.
I'm not a pro coder when it comes to scripting, any ideas? I haven't found much information on this specific topic.
With jquery/javascript you can use window.close()
An example using a button...
html
<button id="close">Close</button>
jquery
$(document).ready(function() {
$('#close').click(function(){
window.close();
});
});
For further info...

Close html5 HTMLNotification when link is clicked

I am using createHTMLNotification for a chrome extension. The html for the notification includes a link in it. What im trying to figure out is how to close the notification when the link is clicked. My code is following
var notification = window.webkitNotifications.createHTMLNotification(
"notification.html"
);
notification.show();
The code on the notification.html page fills in the data. This page includes the jquery library. When I try to do:
$('#title > a').click(function() {
notification.cancel();
}
This of course does not work because notification is unknown on this html page. I have also tried to do a notification.onshow during the first part of the code where i create the notification, but this as well produced no results.
Well I figured it out. It was actually a pretty simple fix. All you have to do is in the click event for the href in the notification, add window.close(). This is because according to W3C specification it is a separate window so you can treat it as such
You can try following to set the focus to newly opened tab and close the notification on the way
notification.onclick = function(x) { window.focus(); this.cancel(); };
notification.show();