Solved

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

Posted on 2001-07-18
4
1,556 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
Comment Utility
<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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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'…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
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…

763 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now