Computer Forums

Member Login

Remember Me? Sign Up! | Forgot Password
 
Slogan
 
Computer Forums > Programmers Lounge > Programming Discussions » javascript will not enter function
Closed Thread
Old 04-01-2005, 07:31 AM   #1 (permalink)
 
Newb Techie

Join Date: Apr 2005

Posts: 1

gorman

Default javascript will not enter function

I'm relatively new at JavaScript, but as far as I have gone it seems pretty similar to most other OO programming languages. Relatively. Different syntax, same concept. But for some reason, whenever I try to activate a function by clicking on a link, it won't work.

Code:
<script language="JavaScript" type="text/javascript">

//more code here...

function testfunction()
{
	alert("this works");
}

</script></head> <body bgcolor="454549" leftmargin="0">
<script>
var lastsubmitted
</script>
<a class="anchorStyle" onMouseDown="alert('this works')">Slideshow</a>

<a class="anchorStyle" onMouseDown="testfunction()">Next</a>
I know it's not my HTML, because the straight out "alert('this works')" link (the second one down) works perfectly well, but as soon as i put it in a function it refuses to go. What am I doing wrong?

Apologies if this is hopelessly pathetic. As I said, I'm relatively new at JS.
gorman is offline  
Old 04-02-2005, 02:57 PM   #2 (permalink)
 
Ultra Techie

Join Date: Oct 2003

Posts: 544

fitzjj

Default

it all work fine for me, i tested with firefox, opera and IE with no problems. You do have JavaScript enabled and everything dont you?

other than that i would suggest that perhaps some of your code that you have left out has incorrect syntax or something that messes up everything else - the problem with JavaScript is that it is tricky to spot errors.

if you post all of your code i'll have a look at the rest for you
fitzjj is offline  
Old 04-03-2005, 04:27 PM   #3 (permalink)
 
Super Techie

Join Date: Mar 2005

Posts: 259

C.Ingram

Send a message via AIM to C.Ingram Send a message via Yahoo to C.Ingram
Default

A better way to call functions like that is to set the links href="javascript:void(0);" and onclick="your_function();". It does the same thing, but is a little more explicit.
__________________
Christopher Ingram
Principal Consultant, Souken Group, LLC.
C.Ingram@SoukenGroup.com
(856) 392 5244 -- (866) Go Souken
C.Ingram is offline  
 
Closed Thread

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On