473,388 Members | 1,375 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

javascript url

What I've been trying to do is this:

<a href="javascript:thisFunction(); return false;">Do This</a>

It doesn't work, so I'm doing this:

<a href="javascript:void();" onclick="thisFunction(); return false;">Do
This</a>

And I'm not even sure if I'm doing the void properly. Is there a way to
accomplish this without using the void ?

Later, Art.

Jul 23 '05 #1
5 1323
Art X wrote:
What I've been trying to do is this:

<a href="javascript:thisFunction(); return false;">Do This</a>

It doesn't work, so I'm doing this:

<a href="javascript:void();" onclick="thisFunction(); return false;">Do
This</a>

And I'm not even sure if I'm doing the void properly. Is there a way to
accomplish this without using the void ?


<a href="nonJavascriptPage.html;"
onclick="thisFunction(); return false;">
Do This
</a>

Jul 23 '05 #2
Mick White wrote:
<a href="nonJavascriptPage.html;"
onclick="thisFunction(); return false;">
Do This
</a>


Or better:

<a href="JS-failed.html" onclick="return thisFunction()">

where thisFunction() has a suitable return statement.

This lets you deal with circumstances such as a function that uses W3C DOM
to dynamically add content. It would fail in Netscape 4 and IE 4, but a
plain return false wouldn't, so such users would get nothing (except JS
errors).

--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is
Jul 23 '05 #3
David Dorward <do*****@yahoo.com> writes:
<a href="JS-failed.html" onclick="return thisFunction()">

where thisFunction() has a suitable return statement.

This lets you deal with circumstances such as a function that uses W3C DOM
to dynamically add content. It would fail in Netscape 4 and IE 4, but a
plain return false wouldn't, so such users would get nothing (except JS
errors).


Well, if you have errors, the exection will never reach the "return
false", and the link would be followed anyway :)

Still, it's a good suggestion, as it allows the function to decide,
gracefully, to have the link followed.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 23 '05 #4
So in any case I should have the actual page (or an alternate) in the
link ?

Thanks for the help, I appreciate it.

Later, Art.

Jul 23 '05 #5
Art X wrote:

What is the context of this message? Please quote relevent material! :)
So in any case I should have the actual page (or an alternate) in the
link ?


Yes. If you attach JavaScript to a link and do not want the user to be
directed to another page when they click on said link, then set the value
of the href to a page suitable for users for whom the JS does not function
correctly (which, in an ideal world, usually means duplicating the client
side code on the server.).
--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is
Jul 23 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.