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&amp;ID=6&amp;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&amp;ID=<http://my.server.com/mywebpage.py?query=downloadfile&ID=>'
>> + ID + '&amp;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

Reply via email to