I have a big problem. I've made a simple Google Chrome plugin (based on the old Youtube Video Downloader) but I have some problems with it. The first problem is that it won't pop up a new save window on click, but opens a new page with the video in the default Chrome player. The second is, that when the user clicks right click-save, they won't get the video name but a standardized name.
Is there any way to make a file save dialog with a specified file save name?
EDIT:
The link is automatically generated based on the Youtube video link, this way:
document.getElementById('watch-description-body').innerHTML+='<button id="download-youtube-video-button" data-button-listener="" data-tooltip-timer="300" class="yt-uix-button yt-uix-tooltip" data-tooltip="Right-click and click Save Link As... to download" type="button">'+'FLV</button>' ;
So basically it ads a button to the existing page, with a specified link:
http://www.youtube.com/get_video?video_id='+video_id+'&t='+t+'=
Where video_id is the Video ID number, and t is the time the player was stopped.
1) To 'force' a download, rather than a page load you will need to deliver a Content-Disposition: attachment HTTP header.
Or you could just use the new HTML5 property download in the anchor tag of your html.
The code will look something like
<a download href="path/to/the/download/file"> Clicking on this link will force download the file</a>
It works on firefox and chrome latest version. It also seems to work IE6+
Related
How to open link (provided in youtube video) in external browser instead of app.
when i click on the link in description then a page opens in youtube app and shows the webpage but i want to display in external browsers, so what code i can do in my website to make this change.
Use a target attribute in your anchor.
target="_blank" should do the trick.
<a target="_blank" href="daily-cat-video">click to see the cats</a>
If you want to get fancier and include window sizes and things, look at
Opening new window in HTML for target="_blank"
an window.open.
. this will let you have more control over the window that gets open.
If you are in your mobile app, then opening in the youtube app is normal for android. It looks at the intent and will present the user with the options that can handle that intent.
If it gets a youtube video, it will ask the user if they want to open it in youtube 'just once, or always' as well as give the user other apps that can handle the intent too, i.e chrome,
Actually this is what I'm trying to do. I have a form and when a user fills that form it goes to a thank you page where thank you message is displayed. Now what I'm trying to do is as soon as the thank you page opens a pdf file should start downloading without the user clicking anywhere on the page. I tried to find a solution by searching but almost all of them have given a solution where one link is provided and user have to click that link to download her pdf. But that is not what I want. And I want to achieve that using Javascript or jQuery only, no server side language.
A clarification:- PDF download on clicking a link is already working. What I want is PDF to download as soon as thank you page opens. I know logically this should not happen because by doing this anyone can set any number of files to be downloaded as soon as their page opens and fill your local drive. But my client wants only this thing to happen.
Calling click() for the user on an other-wise working link should do the trick:
<html>
download pdf
<script>
var link = document.getElementById("link");
link.click()
</script>
</html>
You can do it, in the HEAD tag:
<meta http-equiv="refresh" content="0; url=yourfile.pdf">
This will work also with browsers without JavaScript, and as soon as the the head tags loaded.
a working example:
See an example on github
You can use ajax to hit the url when the page loads.
EDIT: You might want to check this out https://stackoverflow.com/a/29266135/4549494
I need to execute a page that contains an audio player when I click the extension I'm building. But when I click outside of it, the player stops. I need to keep it running.
I tried to use the "background" attribute on the manifest file, but I think it only works with javascript files.
Any sugestions?
You should use a background page or an event page (according to a permanent or temporary need).
http://developer.chrome.com/extensions/background_pages.html
You just have to provide a page attribute to the background property. As mentioned in the above page.
I wish to have a user click on a link to a video file and then have a dialog box open for them to save to file. I don't wish for the browser to open quicktime or any other plugin to process the video. how can this be done?
You can't do this with JavaScript alone. Your server should set Content-Disposition header to attachment. For example in php you do something like header("Content-Disposition:attachment;");
Normal: download
The reason I can't do this is it's on a Wordpress installation with a plugin (wpaudio) which turns every mp3 filein the code into a mini player which when clicked streams the file. So that link above would appear as a link, with a play button beside it, when clicked would stream the file, and not prompt the download dialogue box. With 99% of the mp3 files on this site that's exactly what is needed.
However for one file, I need to enable the user to click the linked word download, and get the save or open dialogue box, along with subsequent progress bar (if enabled in his browser preferences). PHP or Javascript is fine, either will do, anybody know how to get that working?
According to the plugin site you linked to:
Convert all mp3 links
To turn every mp3 link on your blog into a player, select Convert all mp3 links in the WPaudio settings.
Convert some mp3 links
For any mp3 link you'd like to convert to a player, add the wpaudio class like this:
Artist - Song
So, you probably just don't want to have to go give every link that class right? So, use JavaScript to do it. Give the links you don't want converted a class of no-wpaudio or something, and use JavaScript to add the class to all the links without the no-wpaudio class. Hopefully you are using jQuery:
$("a[href$='.mp3']:not(.no-wpaudio)").addClass("wpaudio");
If not, what a pain, but it can be done. Let me know if you want the non-jQuery code.