My problem with target='_blank' is the opening of a new tab/window which
hides the GUI until the user closes it. I dislike the aesthetic which may
just be me being picky.
I *have* learned that it is a bad thing to reuse the current page reference
to trigger downloads though because, as you say, this could wreak havoc
with applets of any kind on the page.
Thanks,
Shane
On Wed, Apr 17, 2013 at 6:06 AM, Robert Hanson <hans...@stolaf.edu> wrote:
> I'm pretty sure target=_blank is what you want. But your iFrame idea seems
> to work as well. Either way, it's important not to use <a href=...> on a
> page you don't want to rewrite.
>
>
> On Tue, Apr 16, 2013 at 10:46 PM, Shane Ó Conchúir
> <spiderb...@gmail.com>wrote:
>
>> Hi,
>>
>> Sorry, I should have been clearer above. The webpage displays information
>> about protein structures. There are links to download PyMOL sessions, PDB
>> files, PDF files etc. so the user can open the files locally. The behavior
>> I want is that a user can *left-click* on a link to open a 'Save to'
>> dialog. The webpage also has a JSmol applet which can be used to view the
>> structures inside the page. The files to be downloaded are not meant to be
>> used by the JSmol applet.
>> > Q: what if you use <a target=_blank href=?.....>
>>
>> This is a very good point. I think that will open a separate
>> tab/window (I can test this tomorrow) which interrupts the user's
>> interaction with the webpage which is why I did not take this approach.
>> Therefore, my problem is particular to this concern.
>> > Q: What is the purpose of this link? You say this reloads the whole
>> page? Why do you want to do that?
>>
>> The purpose of the links are to download the PSE, PDB, etc. files. I do
>> not wish to reload the page which is why I omit the target and set the
>> content disposition to 'attachment'. This seems to avoid a page reload from
>> the user's perspective - the behavior is as if they had right-clicked a
>> link to the file and chosen to save it to disk - however I suspect that a
>> page reload event is triggered which probably calls the garbage collector.
>>
>> > Q: Prints this where? How?
>> > I'm not familiar with using attachment with page loads. I think it just
>> destroys the applet. Any page load would be disastrous for an applet of any
>> kind.
>> > Q: Can't you avoid a page download?
>>
>> This file is 'printed' to the user's browser as a HTTP response.
>> 'printed' is probably the wrong term to use.
>> From the user's perspective, no page reload happens but I suspect that
>> behind the scenes, some event is triggered which kills the JSmol applet -
>> and would probably kill any other applet as you say.
>>
>> One way to avoid a page load is to open a new tab/window as you suggest
>> above. This would probably fix the problem but would make the interface
>> less user-friendly as they would then have to close the tab. I could have
>> the tab auto-close but then there could be a brief interruption. The iframe
>> solution behaves nicely.
>> > Q: Why not just load the file using JSmol's functions and AJAX?
>>
>> I was not clear about this in my previous email. The downloadable files
>> are not meant to be loaded into JSmol.
>>
>> In summary, I am doing something particular where I wish to avoid opening
>> new tabs/windows when a user tries to download a file but do so without
>> breaking applets on the page. One solution to this is using the iframe
>> approach in my first email but there may be better approaches.
>>
>> Thanks,
>> Shane
>>
>>
>> On Tue, Apr 16, 2013 at 7:56 PM, Robert Hanson <hans...@stolaf.edu>wrote:
>>
>>> what if you use
>>>
>>> <a target=_blank href=?.....>
>>>
>>> ?
>>>
>>>
>>>
>>>
>>> On Tue, Apr 16, 2013 at 9:50 PM, Robert Hanson <hans...@stolaf.edu>wrote:
>>>
>>>>
>>>>
>>>>
>>>> On Tue, Apr 16, 2013 at 9:02 PM, Shane Ó Conchúir <spiderb...@gmail.com
>>>> > wrote:
>>>>
>>>>> Hi all,
>>>>>
>>>>> I hit a problem where opening a link on my page which triggers a file
>>>>> download breaks the JSmol applet (jsmol-13.1.14b) in Chrome
>>>>> 23.0.1271.95 under Linux Mint 13 (Maya). I do not know whether this
>>>>> problem exists on other platforms/browsers. I also have a solution which
>>>>> works for me (below) but thought I would share the problem in case this is
>>>>> something the devs wish to look into and also to share the solution for
>>>>> anyone hitting the same problem. Also, someone may point out if there is a
>>>>> simpler fix to mine below / that I was doing something silly :-).
>>>>>
>>>>> I'm doing the following
>>>>>
>>>>> - The page has links to download files from the database. The links
>>>>> have the form
>>>>> <a href='?query=downloadfile&ID=6&download=gz'>...</a>
>>>>>
>>>>
>>>> Q: What is the purpose of this link? You say this reloads the whole
>>>> page? Why do you want to do that?
>>>>
>>>>
>>>>> Clicking on a link causes a page reload which reads the file from
>>>>> the database and prints the following:
>>>>>
>>>>
>>>> Q: Prints this where? How?
>>>>
>>>>
>>>>
>>>>> Content-Type: application/x-gzip
>>>>> Content-Disposition: attachment; filename="somefilename"
>>>>> Content-Length: somelength
>>>>>
>>>>> [contents of file]
>>>>>
>>>>> Because the new page is an attachment, the page does not visibly
>>>>> reload so the user gets the usual file download dialog. However, the page
>>>>> load breaks the JSmol applet, maybe due to garbage collection.
>>>>>
>>>>
>>>> I'm not familiar with using attachment with page loads. I think it just
>>>> destroys the applet. Any page load would be disastrous for an applet of any
>>>> kind.
>>>>
>>>> Q: Can't you avoid a page download?
>>>>
>>>>
>>>>
>>>>>
>>>>> My solution to this was to use an iframe. First, I replaced the links
>>>>> with ones as follows:
>>>>> <a id='PSELink-6' href=''>...</a>
>>>>> Then I include the following in $(document).ready:
>>>>> $('[id^="PSELink-"]').click(function() {
>>>>> this_id = $(this).attr('id');
>>>>> ID = parseInt(this_id.split('-')[1]);
>>>>> var iframe = document.createElement("iframe");
>>>>> iframe.src = '
>>>>> http://my.server.com/mywebpage.py?query=downloadfile&ID=<http://my.server.com/mywebpage.py?query=downloadfile&ID=>'
>>>>> + ID + '&download=gz';
>>>>> iframe.style.display = "none";
>>>>> document.body.appendChild(iframe);
>>>>> return false; // prevent page reload
>>>>> });
>>>>>
>>>>> Clicking on the link still triggers a file download but (I'm guessing
>>>>> since the page does not reload) the JSmol applet continues to function.
>>>>>
>>>>>
>>>> Q: Why not just load the file using JSmol's functions and AJAX?
>>>>
>>>>
>>>>
>>>>> Regards,
>>>>> Shane
>>>>>
>>>>>
>>>>>
>>>>> ------------------------------------------------------------------------------
>>>>> Precog is a next-generation analytics platform capable of advanced
>>>>> analytics on semi-structured data. The platform includes APIs for
>>>>> building
>>>>> apps and a phenomenal toolset for data science. Developers can use
>>>>> our toolset for easy data analysis & visualization. Get a free account!
>>>>> http://www2.precog.com/precogplatform/slashdotnewsletter
>>>>> _______________________________________________
>>>>> Jmol-developers mailing list
>>>>> Jmol-developers@lists.sourceforge.net
>>>>> https://lists.sourceforge.net/lists/listinfo/jmol-developers
>>>>>
>>>>>
>>>>
>>>>
>>>> --
>>>> Robert M. Hanson
>>>> Larson-Anderson Professor of Chemistry
>>>> Chair, Chemistry Department
>>>> St. Olaf College
>>>> Northfield, MN
>>>> http://www.stolaf.edu/people/hansonr
>>>>
>>>>
>>>> If nature does not answer first what we want,
>>>> it is better to take what answer we get.
>>>>
>>>> -- Josiah Willard Gibbs, Lecture XXX, Monday, February 5, 1900
>>>>
>>>>
>>>
>>>
>>> --
>>> Robert M. Hanson
>>> Larson-Anderson Professor of Chemistry
>>> Chair, Chemistry Department
>>> St. Olaf College
>>> Northfield, MN
>>> http://www.stolaf.edu/people/hansonr
>>>
>>>
>>> If nature does not answer first what we want,
>>> it is better to take what answer we get.
>>>
>>> -- Josiah Willard Gibbs, Lecture XXX, Monday, February 5, 1900
>>>
>>>
>>>
>>> ------------------------------------------------------------------------------
>>> Precog is a next-generation analytics platform capable of advanced
>>> analytics on semi-structured data. The platform includes APIs for
>>> building
>>> apps and a phenomenal toolset for data science. Developers can use
>>> our toolset for easy data analysis & visualization. Get a free account!
>>> http://www2.precog.com/precogplatform/slashdotnewsletter
>>> _______________________________________________
>>> Jmol-developers mailing list
>>> Jmol-developers@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/jmol-developers
>>>
>>>
>>
>>
>> ------------------------------------------------------------------------------
>> Precog is a next-generation analytics platform capable of advanced
>> analytics on semi-structured data. The platform includes APIs for building
>> apps and a phenomenal toolset for data science. Developers can use
>> our toolset for easy data analysis & visualization. Get a free account!
>> http://www2.precog.com/precogplatform/slashdotnewsletter
>> _______________________________________________
>> Jmol-developers mailing list
>> Jmol-developers@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/jmol-developers
>>
>>
>
>
> --
> Robert M. Hanson
> Larson-Anderson Professor of Chemistry
> Chair, Chemistry Department
> St. Olaf College
> Northfield, MN
> http://www.stolaf.edu/people/hansonr
>
>
> If nature does not answer first what we want,
> it is better to take what answer we get.
>
> -- Josiah Willard Gibbs, Lecture XXX, Monday, February 5, 1900
>
>
>
> ------------------------------------------------------------------------------
> Precog is a next-generation analytics platform capable of advanced
> analytics on semi-structured data. The platform includes APIs for building
> apps and a phenomenal toolset for data science. Developers can use
> our toolset for easy data analysis & visualization. Get a free account!
> http://www2.precog.com/precogplatform/slashdotnewsletter
> _______________________________________________
> Jmol-developers mailing list
> Jmol-developers@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/jmol-developers
>
>
------------------------------------------------------------------------------
Precog is a next-generation analytics platform capable of advanced
analytics on semi-structured data. The platform includes APIs for building
apps and a phenomenal toolset for data science. Developers can use
our toolset for easy data analysis & visualization. Get a free account!
http://www2.precog.com/precogplatform/slashdotnewsletter
_______________________________________________
Jmol-developers mailing list
Jmol-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jmol-developers