Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2001-07-18
4
Medium Priority
?
1,598 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 75

Accepted Solution

by:
Michel Plungjan earned 200 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
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…

609 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