Re: [WSG] introducing a prompt to download or open a pdf
Reply Chris, Macs do have a right click (right-click being a geenral Microsoft / PC term) Holding down control or the new mouse Apple releases with a right click option. William Chris Price wrote: I would use the file name (or description) as a hyperlink. Its good to have the file size so the visitor knows what they're dealing with. I link to a php page for pdf downloads. The header of the page ensures that the file is served as a pdf not html which means that an option is presented asking the user whether they want to save or view the pdf. This way you're fixing how the file is to be served rather than letting the browser decide. The same page can be used for any format (Word, Excel etc.). The file type is put in the link as a query. I have seen many sites where the link opens to a new window but I am then presented with the same save/view option and left with an empty window and its all very messy. BTW Macs don't have a right click. Paul Minty wrote: I'd recommend displaying with a PDF icon, the text 'PDF' and a file size (in Kb or Mb). I suggest setting the target to a new window, then the user can righ click to save. If you want to go further, I'd suggest having two links labelled 'open' and 'save'. You could put in a pop-up with the option; but I think that this would break the expected behaviour more. You could also detect the connection speed and suggest a download time; but this may not give you much ROI. Kind Regards *** List Guidelines: http://webstandardsgroup.org/mail/guidelines.cfm Unsubscribe: http://webstandardsgroup.org/join/unsubscribe.cfm Help: [EMAIL PROTECTED] ***
Re: [WSG] introducing a prompt to download or open a pdf
On 17 Oct 2007, at 04:50, Chris Knowles wrote: Kit Grose wrote: Just a note: Your function doesn't currently use the RegExp function for anything useful (you might as well use indexOf). RegExp is the right way to do it, though, so you can enforce word boundaries to match complete classNames only (if I want all a.pop to be new window links, I wouldn't want a.popcorn to turn into a popup window). See http://snook.ca/archives/javascript/your_favourite_1/ for more info (specifically the update) on how to enforce word boundaries but allow for multiple classnames. good point - here it is modified to use word boundaries: Word boundaries aren't right either; for exmple, they will match a hyphen, so matching on some-thing will match some-thing-else. As per the HTML spec, class names are space-separated, so you need to match on spaces and the beginning or end of the string. To save time, Robert Nyman has already been through all these problems, so have a look at his ultimate getElementsByClassName: http://www.robertnyman.com/2005/11/07/the-ultimate- getelementsbyclassname/ including the comment from Bruce Weirdan explaining the above: http://www.robertnyman.com/2005/11/07/the- ultimate-getelementsbyclassname/#comment-1583 HTH, Nick. -- Nick Fitzsimons http://www.nickfitz.co.uk/ *** List Guidelines: http://webstandardsgroup.org/mail/guidelines.cfm Unsubscribe: http://webstandardsgroup.org/join/unsubscribe.cfm Help: [EMAIL PROTECTED] ***
Re: [WSG] introducing a prompt to download or open a pdf
Nick Fitzsimons wrote: Word boundaries aren't right either; for exmple, they will match a hyphen, so matching on some-thing will match some-thing-else. As per the HTML spec, class names are space-separated, so you need to match on spaces and the beginning or end of the string. of course, class names are separated by whitespace so hopefully this is it... function setNewWindowLinks(className) { var tags = document.getElementsByTagName('a'); var re = new RegExp('\\s' + className + '\\s'); if (tags.length 0) { for (var i = 0; i tags.length; i++) { if (tags[i].className.search(re) != -1) { tags[i].onclick = function() { window.open(this.href, '_blank'); return false; } } } } } *** List Guidelines: http://webstandardsgroup.org/mail/guidelines.cfm Unsubscribe: http://webstandardsgroup.org/join/unsubscribe.cfm Help: [EMAIL PROTECTED] ***
Re: [WSG] introducing a prompt to download or open a pdf
On 17 Oct 2007, at 13:47, Chris Knowles wrote: Nick Fitzsimons wrote: Word boundaries aren't right either; for exmple, they will match a hyphen, so matching on some-thing will match some-thing-else. As per the HTML spec, class names are space-separated, so you need to match on spaces and the beginning or end of the string. of course, class names are separated by whitespace so hopefully this is it... var re = new RegExp('\\s' + className + '\\s'); Nope, that won't match thing to thing, only to thing - you need to check for the start or end of the string as well as a space :-) HTH, Nick. -- Nick Fitzsimons http://www.nickfitz.co.uk/ *** List Guidelines: http://webstandardsgroup.org/mail/guidelines.cfm Unsubscribe: http://webstandardsgroup.org/join/unsubscribe.cfm Help: [EMAIL PROTECTED] ***
Re: [WSG] introducing a prompt to download or open a pdf
Nick Fitzsimons wrote: On 17 Oct 2007, at 13:47, Chris Knowles wrote: Nick Fitzsimons wrote: Word boundaries aren't right either; for exmple, they will match a hyphen, so matching on some-thing will match some-thing-else. As per the HTML spec, class names are space-separated, so you need to match on spaces and the beginning or end of the string. of course, class names are separated by whitespace so hopefully this is it... var re = new RegExp('\\s' + className + '\\s'); Nope, that won't match thing to thing, only to thing - you need to check for the start or end of the string as well as a space :-) HTH, Nick. sorry Nick, as stated in your previous post, whitespace and end of lines. This should cover the 4 possiblities: thing thing thing thing var re = new RegExp((^|\\s) + className + (\\s|$)) or better still, use this get elements by class function you mentioned then process the elements: http://www.robertnyman.com/2005/11/07/the-ultimate-getelementsbyclassname/ -- Chris Knowles *** List Guidelines: http://webstandardsgroup.org/mail/guidelines.cfm Unsubscribe: http://webstandardsgroup.org/join/unsubscribe.cfm Help: [EMAIL PROTECTED] ***
Re: [WSG] introducing a prompt to download or open a pdf
My pet hate is people forcing pdfs to open in browser windows with javascript! A plain old ordinary link at least lets you right click and download - some of us hate having the browser locked up for ages locked up waiting for the slow pdf plugin to load. I think anything that takes more than a few seconds to load should NEVER be used as a browser plugin ... its just too annoying.. Maybe one day browsers might load plugins as seperate processes so that they can be killed if they take too long to load ... ...? well I can hope for this... :-) because there will always be someone out there inconsiderate enough force such a plugin to be used! *** List Guidelines: http://webstandardsgroup.org/mail/guidelines.cfm Unsubscribe: http://webstandardsgroup.org/join/unsubscribe.cfm Help: [EMAIL PROTECTED] ***
Re: [WSG] introducing a prompt to download or open a pdf
By including an icon (and a title attribute) that indicates that the pdf will open in a new window, the knowledgeable user can easily right click if she wishes to override and take some other action. That's how divaPOP works. This seems to me to be the best of both worlds: novices will see the pdf in a new window so closing that window will not lose the site, and savvy users can right-click just as they would if the link were not scripted to open in a popup. Seems good to me. -- E. Michael Brandt www.divaHTML.com divaPOP : standards-compliant popup windows divaGPS : you-are-here menu highlighting divaFAQ : FAQ pages with pizazz www.valleywebdesigns.com/vwd_Vdw.asp JustSo PictureWindow JustSo PhotoAlbum, et alia -- *** List Guidelines: http://webstandardsgroup.org/mail/guidelines.cfm Unsubscribe: http://webstandardsgroup.org/join/unsubscribe.cfm Help: [EMAIL PROTECTED] ***
[WSG] introducing a prompt to download or open a pdf
i know that this has come up before, but would someone point me to best practices to introduce a prompt to open or download a pdf or any file for that matter? dwain -- dwain alford The artist may use any form which his expression demands; for his inner impulse must find suitable expression. Kandinsky *** List Guidelines: http://webstandardsgroup.org/mail/guidelines.cfm Unsubscribe: http://webstandardsgroup.org/join/unsubscribe.cfm Help: [EMAIL PROTECTED] ***
Re: [WSG] introducing a prompt to download or open a pdf
debatable about opening in new windows but its best to use a pdf icon with size next to the link. On 10/16/07, dwain [EMAIL PROTECTED] wrote: i know that this has come up before, but would someone point me to best practices to introduce a prompt to open or download a pdf or any file for that matter? dwain -- dwain alford The artist may use any form which his expression demands; for his inner impulse must find suitable expression. Kandinsky *** List Guidelines: http://webstandardsgroup.org/mail/guidelines.cfm Unsubscribe: http://webstandardsgroup.org/join/unsubscribe.cfm Help: [EMAIL PROTECTED] *** -- JP2 Designs http://www.jp2designs.com http://www.germworks.net *** List Guidelines: http://webstandardsgroup.org/mail/guidelines.cfm Unsubscribe: http://webstandardsgroup.org/join/unsubscribe.cfm Help: [EMAIL PROTECTED] ***
RE: [WSG] introducing a prompt to download or open a pdf
Sent: Tuesday, 16 October 2007 4:16 PM To: web standards group Subject: [WSG] introducing a prompt to download or open a pdf i know that this has come up before, but would someone point me to best practices to introduce aprompt to open or download a pdf or any file for that matter? dwain Dwain, Funnily enough I'm working on a design pattern for this, as it doesn't seem to be documented very well in the usual design pattern collections. I'd recommend displaying with a PDF icon, the text 'PDF' and a file size (in Kb or Mb). I suggest setting the target to a new window, then the user can righ click to save. If you want to go further, I'd suggest having two links labelled 'open' and 'save'. You could put in a pop-up with the option; but I think that this would break the expected behaviour more. You could also detect the connection speed and suggest a download time; but this may not give you much ROI. It's always good to have an HTML version of the content; but you've probably already thought of that. I'd be keen to know other people's thoughts; especially if you know of any design patterns for this. Cheers Paul Paul Minty Director mintleaf studio We design create stylish websites Post: Box 6 108 Flinders Street Melbourne VIC 3000 Level 2 108 Flinders Street Melbourne T. 03 9662 9344 F. 03 9662 9255 M. 0418 307 475 [EMAIL PROTECTED] www.mintleafstudio.com.au *** List Guidelines: http://webstandardsgroup.org/mail/guidelines.cfm Unsubscribe: http://webstandardsgroup.org/join/unsubscribe.cfm Help: [EMAIL PROTECTED] ***
RE: [WSG] introducing a prompt to download or open a pdf
Responding to Paul, I'm doing the same, with the addition of a note to the user that a new window will open upon activation of the icon/hyperlink. Some may think this is overkill, but I'd rather have the user aware of what's going to occur. Kind regards, Frank -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Paul Minty Sent: Tuesday, 16 October, 2007 8:53 AM To: wsg@webstandardsgroup.org Subject: RE: [WSG] introducing a prompt to download or open a pdf Sent: Tuesday, 16 October 2007 4:16 PM To: web standards group Subject: [WSG] introducing a prompt to download or open a pdf i know that this has come up before, but would someone point me to best practices to introduce aprompt to open or download a pdf or any file for that matter? dwain Dwain, Funnily enough I'm working on a design pattern for this, as it doesn't seem to be documented very well in the usual design pattern collections. I'd recommend displaying with a PDF icon, the text 'PDF' and a file size (in Kb or Mb). I suggest setting the target to a new window, then the user can righ click to save. If you want to go further, I'd suggest having two links labelled 'open' and 'save'. You could put in a pop-up with the option; but I think that this would break the expected behaviour more. You could also detect the connection speed and suggest a download time; but this may not give you much ROI. It's always good to have an HTML version of the content; but you've probably already thought of that. I'd be keen to know other people's thoughts; especially if you know of any design patterns for this. Cheers Paul Paul Minty Director mintleaf studio We design create stylish websites Post: Box 6 108 Flinders Street Melbourne VIC 3000 Level 2 108 Flinders Street Melbourne T. 03 9662 9344 F. 03 9662 9255 M. 0418 307 475 [EMAIL PROTECTED] www.mintleafstudio.com.au *** List Guidelines: http://webstandardsgroup.org/mail/guidelines.cfm Unsubscribe: http://webstandardsgroup.org/join/unsubscribe.cfm Help: [EMAIL PROTECTED] *** *** List Guidelines: http://webstandardsgroup.org/mail/guidelines.cfm Unsubscribe: http://webstandardsgroup.org/join/unsubscribe.cfm Help: [EMAIL PROTECTED] ***
Re: [WSG] introducing a prompt to download or open a pdf
I like your suggestion of including the file size, but just as an aside: Kb stands for Kilobit, not Kilobyte (which you probably mean). Both letters should be in caps to mean Kilobytes/Megabytes. I'd think (as a user) if you use the terminology 'download' for the link, the PDF should be sent with a force-download Content-type header if possible (so it doesn't try to view it). My two cents, Kit *** List Guidelines: http://webstandardsgroup.org/mail/guidelines.cfm Unsubscribe: http://webstandardsgroup.org/join/unsubscribe.cfm Help: [EMAIL PROTECTED] ***
Re: [WSG] introducing a prompt to download or open a pdf
I would use the file name (or description) as a hyperlink. Its good to have the file size so the visitor knows what they're dealing with. I link to a php page for pdf downloads. The header of the page ensures that the file is served as a pdf not html which means that an option is presented asking the user whether they want to save or view the pdf. This way you're fixing how the file is to be served rather than letting the browser decide. The same page can be used for any format (Word, Excel etc.). The file type is put in the link as a query. I have seen many sites where the link opens to a new window but I am then presented with the same save/view option and left with an empty window and its all very messy. BTW Macs don't have a right click. Paul Minty wrote: I'd recommend displaying with a PDF icon, the text 'PDF' and a file size (in Kb or Mb). I suggest setting the target to a new window, then the user can righ click to save. If you want to go further, I'd suggest having two links labelled 'open' and 'save'. You could put in a pop-up with the option; but I think that this would break the expected behaviour more. You could also detect the connection speed and suggest a download time; but this may not give you much ROI. Kind Regards -- Chris Price Choctaw [EMAIL PROTECTED] http://www.choctaw.co.uk Tel. 01524 825 245 Mob. 0777 451 4488 Beauty is in the Eye of the Beholder while Excellence is in the Hand of the Professional ~~~ -+- Sent on behalf of Choctaw Media Ltd -+- ~~~ Choctaw Media Limited is a company registered in England and Wales with company number 04627649 Registered Office: Lonsdale Partners, Priory Close, St Mary's Gate, Lancaster LA1 1XB United Kingdom *** List Guidelines: http://webstandardsgroup.org/mail/guidelines.cfm Unsubscribe: http://webstandardsgroup.org/join/unsubscribe.cfm Help: [EMAIL PROTECTED] ***
Re: [WSG] introducing a prompt to download or open a pdf
On 10/16/07, Paul Minty [EMAIL PROTECTED] wrote: I'd recommend displaying with a PDF icon, the text 'PDF' and a file size (in Kb or Mb). I suggest setting the target to a new window, then the user can righ click to save. here's the address where the pdf links are. i did not put the pdf icon (don't know where to get one) but i do say that it's a pdf and the size: http://www.alforddesigngroup.com/design-graphic-studio.html -- dwain alford The artist may use any form which his expression demands; for his inner impulse must find suitable expression. Kandinsky *** List Guidelines: http://webstandardsgroup.org/mail/guidelines.cfm Unsubscribe: http://webstandardsgroup.org/join/unsubscribe.cfm Help: [EMAIL PROTECTED] ***
Re: [WSG] introducing a prompt to download or open a pdf
On 10/16/07, Kit Grose [EMAIL PROTECTED] wrote: I'd think (as a user) if you use the terminology 'download' for the link, the PDF should be sent with a force-download Content-type header if possible (so it doesn't try to view it). how would you code this force download? dwain -- dwain alford The artist may use any form which his expression demands; for his inner impulse must find suitable expression. Kandinsky *** List Guidelines: http://webstandardsgroup.org/mail/guidelines.cfm Unsubscribe: http://webstandardsgroup.org/join/unsubscribe.cfm Help: [EMAIL PROTECTED] ***
Re: [WSG] introducing a prompt to download or open a pdf
Rather than open a pdf in a browser window albeit the same window or a popup, I prefer that a pdf is either saved to the filesystem or opened by a program external to the browser like Acrobat reader. This behaviour depends on what headers the webserver responds with. In php you can serve a file with: header(Content-type: application/pdf); header(Content-Disposition: attachment); readfile('test.pdf'); this will usually cause the browser to ask whether to save to disk or select a program to open the file with. If you use the following it will load the pdf viewer into the browser window: header(Content-type: application/pdf); header(Content-Disposition: inline); readfile('test.pdf'); So I'd recommend a link with a pdf icon and the file size and then set the headers as in the first example Chris Knowles *** List Guidelines: http://webstandardsgroup.org/mail/guidelines.cfm Unsubscribe: http://webstandardsgroup.org/join/unsubscribe.cfm Help: [EMAIL PROTECTED] ***
Re: [WSG] introducing a prompt to download or open a pdf
dwain wrote: On 10/16/07, Kit Grose [EMAIL PROTECTED] wrote: I'd think (as a user) if you use the terminology 'download' for the link, the PDF should be sent with a force-download Content-type header if possible (so it doesn't try to view it). how would you code this force download? dwain This is what I use: $type = $_GET['type']; $fileName = $_GET['filename'] . . . $type; $mimeType = application/$type; if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 5') or strpos($_SERVER['HTTP_USER_AGENT'], 'Opera 7')) $mimeType = 'application/x-download'; header(content-disposition: attachment; filename = \$fileName\); header(content-type: {$mimeType}); readfile($fileName); where the link would be download.php?filename=mypdftype=pdf Kind Regards -- Chris Price Choctaw [EMAIL PROTECTED] http://www.choctaw.co.uk Tel. 01524 825 245 Mob. 0777 451 4488 Beauty is in the Eye of the Beholder while Excellence is in the Hand of the Professional ~~~ -+- Sent on behalf of Choctaw Media Ltd -+- ~~~ Choctaw Media Limited is a company registered in England and Wales with company number 04627649 Registered Office: Lonsdale Partners, Priory Close, St Mary's Gate, Lancaster LA1 1XB United Kingdom *** List Guidelines: http://webstandardsgroup.org/mail/guidelines.cfm Unsubscribe: http://webstandardsgroup.org/join/unsubscribe.cfm Help: [EMAIL PROTECTED] ***
Re: [WSG] introducing a prompt to download or open a pdf
On 16 Oct 2007, at 08:40, dwain wrote: i did not put the pdf icon (don't know where to get one) http://www.adobe.com/ *** List Guidelines: http://webstandardsgroup.org/mail/guidelines.cfm Unsubscribe: http://webstandardsgroup.org/join/unsubscribe.cfm Help: [EMAIL PROTECTED] ***
Re: [WSG] introducing a prompt to download or open a pdf
On 10/16/07, Nick Fitzsimons [EMAIL PROTECTED] wrote: On 16 Oct 2007, at 08:40, dwain wrote: i did not put the pdf icon (don't know where to get one) http://www.adobe.com/ then where? i've looked under downloads and support. i would think that they would have a place special just for us to obtain one. sorry for the sarcasm, it's late and i can't sleep. no excuse, but... -- dwain alford The artist may use any form which his expression demands; for his inner impulse must find suitable expression. Kandinsky *** List Guidelines: http://webstandardsgroup.org/mail/guidelines.cfm Unsubscribe: http://webstandardsgroup.org/join/unsubscribe.cfm Help: [EMAIL PROTECTED] ***
Re: [WSG] introducing a prompt to download or open a pdf
On 10/16/07, Nick Fitzsimons [EMAIL PROTECTED] wrote: On 16 Oct 2007, at 08:40, dwain wrote: i did not put the pdf icon (don't know where to get one) http://www.adobe.com/ thanks, i found one. where do i put this icon before or after the link? dwain -- dwain alford The artist may use any form which his expression demands; for his inner impulse must find suitable expression. Kandinsky *** List Guidelines: http://webstandardsgroup.org/mail/guidelines.cfm Unsubscribe: http://webstandardsgroup.org/join/unsubscribe.cfm Help: [EMAIL PROTECTED] ***
Re: [WSG] introducing a prompt to download or open a pdf
On 16 Oct 2007, at 10:43, dwain wrote: On 10/16/07, Nick Fitzsimons [EMAIL PROTECTED] wrote: On 16 Oct 2007, at 08:40, dwain wrote: i did not put the pdf icon (don't know where to get one) http://www.adobe.com/ thanks, i found one. where do i put this icon before or after the link? dwain It used to be quite easy to ind the relevant page, but they seem to have let their legal department loose on the site :-( Personally, I include the icon within the link; whether it goes before or after the text of the link is purely a matter of personal preference, or the dictates of the graphic designer. I tend to expect it before: a href=blah.pdfimg src=pdflogo.gifDownload blah.pdf/a Regards, Nick. -- Nick Fitzsimons http://www.nickfitz.co.uk/ *** List Guidelines: http://webstandardsgroup.org/mail/guidelines.cfm Unsubscribe: http://webstandardsgroup.org/join/unsubscribe.cfm Help: [EMAIL PROTECTED] ***
Re: [WSG] introducing a prompt to download or open a pdf
On 10/16/07, Nick Fitzsimons [EMAIL PROTECTED] wrote: On 16 Oct 2007, at 10:43, dwain wrote: On 10/16/07, Nick Fitzsimons [EMAIL PROTECTED] wrote: On 16 Oct 2007, at 08:40, dwain wrote: i did not put the pdf icon (don't know where to get one) http://www.adobe.com/ thanks, i found one. where do i put this icon before or after the link? dwain It used to be quite easy to ind the relevant page, but they seem to have let their legal department loose on the site :-( Personally, I include the icon within the link; whether it goes before or after the text of the link is purely a matter of personal preference, or the dictates of the graphic designer. I tend to expect it before: a href=blah.pdfimg src=pdflogo.gifDownload blah.pdf/a thank you, all of you who have responded have been a big help. cheers, dwain -- dwain alford The artist may use any form which his expression demands; for his inner impulse must find suitable expression. Kandinsky *** List Guidelines: http://webstandardsgroup.org/mail/guidelines.cfm Unsubscribe: http://webstandardsgroup.org/join/unsubscribe.cfm Help: [EMAIL PROTECTED] ***
Re: [WSG] introducing a prompt to download or open a pdf
Hi, Someone suggested using a PDF icon. Is this something you can get from adobe? Simon *** List Guidelines: http://webstandardsgroup.org/mail/guidelines.cfm Unsubscribe: http://webstandardsgroup.org/join/unsubscribe.cfm Help: [EMAIL PROTECTED] ***
Re: [WSG] introducing a prompt to download or open a pdf
They certainly don't make it easy to find - http://www.adobe.com/misc/linking.html#pdficon Someone suggested using a PDF icon. Is this something you can get from adobe? Simon *** List Guidelines: http://webstandardsgroup.org/mail/guidelines.cfm Unsubscribe: http://webstandardsgroup.org/join/unsubscribe.cfm Help: [EMAIL PROTECTED] ***
Re: [WSG] introducing a prompt to download or open a pdf
On Oct 16, 2007, at 12:39 AM, Chris Price wrote: BTW Macs don't have a right click. Hi Chris, Mac has right click. It's just Steve Jobs made it so difficult with his Apple mouse (a piece of pricey junk). If you use Apple mouse, use the combination of control on keyboard + click on mouse, this will open up the right click window for options. I think it worth to include this little info for user education when a web design opted to use right click for download/open new window. tee *** List Guidelines: http://webstandardsgroup.org/mail/guidelines.cfm Unsubscribe: http://webstandardsgroup.org/join/unsubscribe.cfm Help: [EMAIL PROTECTED] ***
Re: [WSG] introducing a prompt to download or open a pdf
Tee G. Peng wrote: Mac has right click. It's just Steve Jobs made it so difficult with his Apple mouse (a piece of pricey junk). If you use Apple mouse, use the combination of control on keyboard + click on mouse, this will open up the right click window for options. I know its not strictly correct to say a Mac doesn't have a right click and I do use the control key (when I have to) but I have used a Mac for 15 years and never felt I was missing a button. I think its because the interface has been so well designed. Kind Regards -- Chris Price Choctaw [EMAIL PROTECTED] http://www.choctaw.co.uk Tel. 01524 825 245 Mob. 0777 451 4488 Beauty is in the Eye of the Beholder while Excellence is in the Hand of the Professional ~~~ -+- Sent on behalf of Choctaw Media Ltd -+- ~~~ Choctaw Media Limited is a company registered in England and Wales with company number 04627649 Registered Office: Lonsdale Partners, Priory Close, St Mary's Gate, Lancaster LA1 1XB United Kingdom *** List Guidelines: http://webstandardsgroup.org/mail/guidelines.cfm Unsubscribe: http://webstandardsgroup.org/join/unsubscribe.cfm Help: [EMAIL PROTECTED] ***
RE: [WSG] introducing a prompt to download or open a pdf
Maybe it's just me, but this: -- $type = $_GET['type']; $fileName = $_GET['filename'] . . . $type; $mimeType = application/$type; if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 5') or strpos($_SERVER['HTTP_USER_AGENT'], 'Opera 7')) $mimeType = 'application/x-download'; header(content-disposition: attachment; filename = \$fileName\); header(content-type: {$mimeType}); readfile($fileName); where the link would be download.php?filename=mypdftype=pdf -- looks terribly insecure to me -- I'm allowed to put whatever I want into the URL until I find something interesting? I think I'd start with download.php?filename=../htpasswdtype= == The information contained in this email and any attachment is confidential and may contain legally privileged or copyright material. It is intended only for the use of the addressee(s). If you are not the intended recipient of this email, you are not permitted to disseminate, distribute or copy this email or any attachments. If you have received this message in error, please notify the sender immediately and delete this email from your system. The ABC does not represent or warrant that this transmission is secure or virus free. Before opening any attachment you should check for viruses. The ABC's liability is limited to resupplying any email and attachments == *** List Guidelines: http://webstandardsgroup.org/mail/guidelines.cfm Unsubscribe: http://webstandardsgroup.org/join/unsubscribe.cfm Help: [EMAIL PROTECTED] ***
Re: [WSG] introducing a prompt to download or open a pdf
John Horner wrote: Maybe it's just me, but this: where the link would be download.php?filename=mypdftype=pdf looks terribly insecure to me -- I'm allowed to put whatever I want into the URL until I find something interesting? I think I'd start with download.php?filename=../htpasswdtype= It's not just you! - Very insecure - breaks all the rules Chris Knowles *** List Guidelines: http://webstandardsgroup.org/mail/guidelines.cfm Unsubscribe: http://webstandardsgroup.org/join/unsubscribe.cfm Help: [EMAIL PROTECTED] ***
Re: [WSG] introducing a prompt to download or open a pdf
that people who author these links without the aid of server side scripting can develop this user experience easily. Anyone seen anything like that? As it happens I offer an inexpensive script, divaPOP (both as a Dreamweaver Extension, and a Standalone script for everyone else) that does exactly that. It is an unobtrusive javascript that adds a pdf icon, right or left of the link, and opens the file in a popup window (which is my own preference since I personally lose websites all the time when I close a pdf file otherwise), all without having to add any hooks to the links at all. Optionally it also adds an icon to external links signifying that they will open in a popup window as well. It's available at http://www.divahtml.com/products/divaPOP/open_popup_windows.php I am also about to release an update that will add an option to automatically add a rel=nofollow attribute to the external links. -- E. Michael Brandt www.divaHTML.com divaPOP : standards-compliant popup windows divaGPS : you-are-here menu highlighting divaFAQ : FAQ pages with pizazz www.valleywebdesigns.com/vwd_Vdw.asp JustSo PictureWindow JustSo PhotoAlbum, et alia -- *** List Guidelines: http://webstandardsgroup.org/mail/guidelines.cfm Unsubscribe: http://webstandardsgroup.org/join/unsubscribe.cfm Help: [EMAIL PROTECTED] ***
Re: [WSG] introducing a prompt to download or open a pdf
John Horner wrote: Maybe it's just me, but this: -- $type = $_GET['type']; $fileName = $_GET['filename'] . . . $type; $mimeType = application/$type; if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 5') or strpos($_SERVER['HTTP_USER_AGENT'], 'Opera 7')) $mimeType = 'application/x-download'; header(content-disposition: attachment; filename = \$fileName\); header(content-type: {$mimeType}); readfile($fileName); where the link would be download.php?filename=mypdftype=pdf I guess to be fair, the author may have simplified the code and not detailed the step of validating the input and ensuring it maps to a legitimate resource. However, I guess the point is that there may be people on this list with limited server side knowledge who would cut and paste something like this, so we should all be careful when submitting code. Chris Knowles *** List Guidelines: http://webstandardsgroup.org/mail/guidelines.cfm Unsubscribe: http://webstandardsgroup.org/join/unsubscribe.cfm Help: [EMAIL PROTECTED] ***
Re: [WSG] introducing a prompt to download or open a pdf
I haven't specifically used code like this, but I do use a dynamic page system (a more advanced version of the '?p=mypage' system commonly seen). To avoid letting people include stuff they should be able to, the page that processes all of this basically has an array where I set which pages it's allowed to access. Anything other than the ones in that list goes to my error page. Something like this is probably the easier, but at the same time, most secure method to accomplish something where a page is dynamically included. Christian Snodgrass Chris Knowles wrote: John Horner wrote: Maybe it's just me, but this: -- $type = $_GET['type']; $fileName = $_GET['filename'] . . . $type; $mimeType = application/$type; if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 5') or strpos($_SERVER['HTTP_USER_AGENT'], 'Opera 7')) $mimeType = 'application/x-download'; header(content-disposition: attachment; filename = \$fileName\); header(content-type: {$mimeType}); readfile($fileName); where the link would be download.php?filename=mypdftype=pdf I guess to be fair, the author may have simplified the code and not detailed the step of validating the input and ensuring it maps to a legitimate resource. However, I guess the point is that there may be people on this list with limited server side knowledge who would cut and paste something like this, so we should all be careful when submitting code. Chris Knowles *** List Guidelines: http://webstandardsgroup.org/mail/guidelines.cfm Unsubscribe: http://webstandardsgroup.org/join/unsubscribe.cfm Help: [EMAIL PROTECTED] *** *** List Guidelines: http://webstandardsgroup.org/mail/guidelines.cfm Unsubscribe: http://webstandardsgroup.org/join/unsubscribe.cfm Help: [EMAIL PROTECTED] ***
Re: [WSG] introducing a prompt to download or open a pdf
Paul Minty wrote: I'd like to see a microformat for this, and an external javascript, so that people who author these links without the aid of server side scripting can develop this user experience easily. Anyone seen anything like that? Cheers Paul heres a generic javascript function I wrote to open links in a new window based on class name. It's only a partial solution to the pdf issue but maybe someone will find it useful anyway. just call it on dom load or window load with the class name you want to use: setNewWindowLinks('new-win'); It'll hijack any 'a' tags with the class name you use and make them open in a popup. If no javascript enabled then it'll just go to that link. The 'a' tag can have multiple class names as well and it'll still work. function setNewWindowLinks(className) { var tags = document.getElementsByTagName('a'); var re = new RegExp(className); if (tags.length 0) { for (var i = 0; i tags.length; i++) { if (tags[i].className.search(re) != -1) { tags[i].onclick = function() { window.open(this.href, '_blank'); return false; } } } } } *** List Guidelines: http://webstandardsgroup.org/mail/guidelines.cfm Unsubscribe: http://webstandardsgroup.org/join/unsubscribe.cfm Help: [EMAIL PROTECTED] ***
Re: [WSG] introducing a prompt to download or open a pdf
On 17/10/2007, at 1:05 PM, Chris Knowles wrote: heres a generic javascript function I wrote to open links in a new window based on class name. It's only a partial solution to the pdf issue but maybe someone will find it useful anyway. just call it on dom load or window load with the class name you want to use: setNewWindowLinks('new-win'); It'll hijack any 'a' tags with the class name you use and make them open in a popup. If no javascript enabled then it'll just go to that link. The 'a' tag can have multiple class names as well and it'll still work. function setNewWindowLinks(className) { var tags = document.getElementsByTagName('a'); var re = new RegExp(className); if (tags.length 0) { for (var i = 0; i tags.length; i++) { if (tags[i].className.search(re) != -1) { tags[i].onclick = function() { window.open(this.href, '_blank'); return false; } } } } } Just a note: Your function doesn't currently use the RegExp function for anything useful (you might as well use indexOf). RegExp is the right way to do it, though, so you can enforce word boundaries to match complete classNames only (if I want all a.pop to be new window links, I wouldn't want a.popcorn to turn into a popup window). See http://snook.ca/archives/javascript/your_favourite_1/ for more info (specifically the update) on how to enforce word boundaries but allow for multiple classnames. Just my thoughts, Kit *** List Guidelines: http://webstandardsgroup.org/mail/guidelines.cfm Unsubscribe: http://webstandardsgroup.org/join/unsubscribe.cfm Help: [EMAIL PROTECTED] *** smime.p7s Description: S/MIME cryptographic signature
Re: [WSG] introducing a prompt to download or open a pdf
Kit Grose wrote: Just a note: Your function doesn't currently use the RegExp function for anything useful (you might as well use indexOf). RegExp is the right way to do it, though, so you can enforce word boundaries to match complete classNames only (if I want all a.pop to be new window links, I wouldn't want a.popcorn to turn into a popup window). See http://snook.ca/archives/javascript/your_favourite_1/ for more info (specifically the update) on how to enforce word boundaries but allow for multiple classnames. good point - here it is modified to use word boundaries: function setNewWindowLinks(className) { var tags = document.getElementsByTagName('a'); var re = new RegExp('\\b' + className + '\\b'); if (tags.length 0) { for (var i = 0; i tags.length; i++) { if (tags[i].className.search(re) != -1) { tags[i].onclick = function() { window.open(this.href, '_blank'); return false; } } } } } *** List Guidelines: http://webstandardsgroup.org/mail/guidelines.cfm Unsubscribe: http://webstandardsgroup.org/join/unsubscribe.cfm Help: [EMAIL PROTECTED] ***