Issue information
-
#000204
Issue Confirmations
-
Yes (0)No (0)
I've noticed for a while that 'Add All To eD2k Client' doesn't work when I'm using Chrome. I decided to look into why today, and think I've figured out the problem and a solution.
The main problem seems to be that Chrome doesn't like the function name 'download' - I'm not sure why, maybe it's a reserved word for Chrome. Using something like 'downloadlinks' works fine! Also, changing the location of the current window (to download a link) whilst also setting a timeout on that window causes the timeout to be lost.
I had a play around with the script, and reworked the function a little. It's not perfect, could probably be improved with some Ajax but it works. I've tested in IE, Firefox & Chrome.
And this is the html I was testing with
The main problem seems to be that Chrome doesn't like the function name 'download' - I'm not sure why, maybe it's a reserved word for Chrome. Using something like 'downloadlinks' works fine! Also, changing the location of the current window (to download a link) whilst also setting a timeout on that window causes the timeout to be lost.
I had a play around with the script, and reworked the function a little. It's not perfect, could probably be improved with some Ajax but it works. I've tested in IE, Firefox & Chrome.
<script type="text/javascript">
// Document is XHTML, so script must be in a CDATA tag to validate
// <![CDATA[
function downloadlinks(i)
{
// download all links
// we create a popup window to download the specified (by id) link
// then call this function again on a timeout to download the next
// the function name 'download' does not seem to work in Chrome - reserved keyword maybe?
if ( i >= 0 ) // validate the input (should always be true)
{
var links = document.getElementsByName('ed2klink');
if ( i < links.length ) // verify we're in the range of links (should always be true)
{
// download the link in a new window
// using ourself (window.location) would lose the function we're about to call
// IE will throw an exception when closing the popup (maybe because it autocloses it?)
// so catch and throw away any exceptions
var popup = window.open(links[i].href);
try
{
popup.close();
}
catch(ex)
{
// eat the exception, yummy.
}
// call ourselves to download the next link, put a small delay on it so the browser doesn't throw it away
// only do this if we're know the next id is valid, saves a costly function call
if ( ((i+1) >= 0) && ((i+1) < links.length) )
{
setTimeout("downloadlinks(" + (i+1) + ")", 500);
}
}
}
}
// ]]>
</script>
And this is the html I was testing with
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>TV Underground</title>
</head>
<body>
<div class="title">Requested eDonkey Links</div><br />
<div style="width:100%; overflow:auto">
<a name="ed2klink" href="ed2k://|file|Person.Of.Interest.1x01.Pilot.HDTV.XviD-ASAP.[tvu.org.ru].avi|367008368|C66D5DE1126C8BC35049CCF3231D0487|h=QAJ4KET3YAYOOKSJ545E75GCW2P4AL5C|/">ed2k://|file|Person.Of.Interest.1x01.Pilot.HDTV.XviD-ASAP.[tvu.org.ru].avi|367008368|C66D5DE1126C8BC35049CCF3231D0487|h=QAJ4KET3YAYOOKSJ545E75GCW2P4AL5C|/</a><br />
<a name="ed2klink" href="ed2k://|file|Person.Of.Interest.1x02.Ghosts.HDTV.XviD-ASAP.[tvu.org.ru].avi|367008720|3C56078EA44991B317E1EF62A1F8A65C|h=YICE7PLNTAFNWFAKERT5XJEOIIDNHO5U|/">ed2k://|file|Person.Of.Interest.1x02.Ghosts.HDTV.XviD-ASAP.[tvu.org.ru].avi|367008720|3C56078EA44991B317E1EF62A1F8A65C|h=YICE7PLNTAFNWFAKERT5XJEOIIDNHO5U|/</a><br />
<a name="ed2klink" href="ed2k://|file|Person.Of.Interest.1x03.Mission.Creep.HDTV.XviD-ASAP.[tvu.org.ru].avi|366989980|B233238FBD0EC1537D10F7EB9792703E|h=WWKRB3EHPVTQMFBORUEWBTXU3R64WYP5|/">ed2k://|file|Person.Of.Interest.1x03.Mission.Creep.HDTV.XviD-ASAP.[tvu.org.ru].avi|366989980|B233238FBD0EC1537D10F7EB9792703E|h=WWKRB3EHPVTQMFBORUEWBTXU3R64WYP5|/</a><br />
</div>
<a href="javascript:void(0);" onclick="downloadlinks(0);">Add All To eD2k Client</a>
<script type="text/javascript">
// Document is XHTML, so script must be in a CDATA tag to validate
// <![CDATA[
function downloadlinks(i)
{
// download all links
// we create a popup window to download the specified (by id) link
// then call this function again on a timeout to download the next
// the function name 'download' does not seem to work in Chrome - reserved keyword maybe?
if ( i >= 0 ) // validate the input (should always be true)
{
var links = document.getElementsByName('ed2klink');
if ( i < links.length ) // verify we're in the range of links (should always be true)
{
// download the link in a new window
// using ourself (window.location) would lose the function we're about to call
// IE will throw an exception when closing the popup (maybe because it autocloses it?)
// so catch and throw away any exceptions
var popup = window.open(links[i].href);
try
{
popup.close();
}
catch(ex)
{
// eat the exception, yummy.
}
// call ourselves to download the next link, put a small delay on it so the browser doesn't throw it away
// only do this if we're know the next id is valid, saves a costly function call
if ( ((i+1) >= 0) && ((i+1) < links.length) )
{
setTimeout("downloadlinks(" + (i+1) + ")", 500);
}
}
}
}
// ]]>
</script>
</body>
</html>
0 user(s) are reading this issue
0 members, 0 guests, 0 anonymous users













