Solved

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

Posted on 2001-07-18
4
1,568 Views
Last Modified: 2012-08-13
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
Comment
Question by:mikezang
  • 3
4 Comments
 
LVL 75

Accepted Solution

by:
Michel Plungjan earned 50 total points
ID: 6294805
<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
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 6294818
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
 
LVL 15

Expert Comment

by:a.marsh
ID: 6295501
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
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 6295934
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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

774 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question