0

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">'+'<a href="http://www.youtube.com/get_video?video_id='+video_id+'&t='+t+'=" style="padding: 2px">FLV</a></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.

2
  • 2
    You are not describing what the plugin does, and where the file comes from. There is no way to help you with the information you provide right now. Commented Apr 22, 2010 at 18:36
  • So it isn't possible to create a new File Download window, with a specified link to save, and a specified name? Commented Apr 25, 2010 at 13:57

2 Answers 2

2

1) To 'force' a download, rather than a page load you will need to deliver a Content-Disposition: attachment HTTP header.

Sign up to request clarification or add additional context in comments.

6 Comments

2) This also allows you to provide a default filename of your choice: Content-Disposition: attachment;filename=FunnyKittensLOL.flv
And to add this custom header, you may need to proxy the original file through a server (ie. your plug-in may need to have a server-side dependency)
That made no sense for me, sorry. Could you please tell me where should I put these lines?
Although, as far as I know, JavaScript is not going to be able to deliver HTTP headers: you'll need something server-side. ie PHP.
Following your edit, I see that you don't control the server from which the download originates, so you won't be able to set the HTTP headers. I don't know what to suggest, then. I suppose this is why the tooltip exists on the button. If it's not your data, you won't be able to control how that data is deliverd, so you'll have to resort to instructing the user how to request it.
|
1

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+

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.