• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1605
  • Last Modified:

onclick="func();return false;" doesn't work

I used function as below, after I cacel or ok in download dialog box, the animation GIF stoped, return false dooesn't work, does anyone help me?

<script language="javascript">
  function goDownload()
  {
  window.location.href="your_file.zip";
  }
  </script>
   
  <a href=javascrip:void" onClick="goDownload();return false;">Download</a>
0
mikezang
Asked:
mikezang
  • 3
1 Solution
 
Michel PlungjanIT ExpertCommented:
<script language="javascript">
function goDownload(filename) {
   window.open(filename,'_blank');
}
</script>
<a href="your_file.zip" onClick="goDownload(this.href);return false;">Download</a>

Michel
0
 
Michel PlungjanIT ExpertCommented:
Or like this:

<script language="javascript">
   function goDownload(filename) {
      window.open('dl.html?'+filename,'_blank');
}
</script>
<a href="your_file.zip" onClick="goDownload(this.href);return false;">Download</a>

where dl.html has

<body onLoad="window.location=window.location.search.substring(1); setTimeout('window.close()',2000)">
0
 
a.marshCommented:
You can use the methods as mentioned by Michel, or you can do this (which is what I think you were trying to do in the first place):

<a href=javascrip:void(0);" onClick="goDownload();">Download</a>


:o)

Ant
0
 
Michel PlungjanIT ExpertCommented:
1. it is javascript:void(0) and that is JS1.1 only
2. The reason the gif died was the window.location changes

Michel
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now