Go Back   CodingForums.com > :: Client side development > JavaScript programming > DOM and JSON scripting

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-07-2009, 12:24 PM   PM User | #1
tempest4000
New Coder

 
Join Date: Feb 2005
Posts: 41
Thanks: 0
Thanked 0 Times in 0 Posts
tempest4000 is an unknown quantity at this point
help with javascript syntax error

objLinks[i].onclick = new Function( "event", "return false;" + objLinks[i].onclick.toString().getFuncBody() );

Im new to javascript and have a functions that returns ans error onthe above line. The error is simpy - syntax error: return false

can anyone see whats wrong?

many thanks
tempest4000 is offline   Reply With Quote
Old 01-07-2009, 03:07 PM   PM User | #2
itsallkizza
Senior Coder

 
Join Date: Oct 2008
Location: Long Beach
Posts: 1,196
Thanks: 36
Thanked 164 Times in 164 Posts
itsallkizza will become famous soon enough
I could be wrong but I don't think getFuncBody is native to Functions.

You can write your own functional code like this:
Code:
function getFuncBody(ref)
	{
	var f = ref.toString().replace(/[^{]+{/,"");
	return f.substring(0,f.length-1);
	}
Or add it via Function.prototype for OO Code.

But since you're returning false before running the original onclick code, it seems to me you're simply wanting to disable the onclick handler which you can do by simply deleting it altogether:
Code:
element.onclick = "";
Or stick to this thread here: http://www.codingforums.com/showthread.php?t=155562

EDIT: Just realized you posted both threads - please stick to one thread at a time.
__________________
Feel free to e-mail me if I forget to respond ;)
ohsosexybrit@gmail.com

Last edited by itsallkizza; 01-07-2009 at 03:10 PM..
itsallkizza is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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

Forum Jump


All times are GMT +1. The time now is 01:14 AM.


Advertisement
Log in to turn off these ads.