Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Feb 2005
    Posts
    41
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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

  • #2
    Senior Coder
    Join Date
    Oct 2008
    Location
    Long Beach
    Posts
    1,196
    Thanks
    36
    Thanked 164 Times in 164 Posts
    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: on readyState 1,2,3 disable all links on page

    EDIT: Just realized you posted both threads - please stick to one thread at a time.
    Last edited by itsallkizza; 01-07-2009 at 03:10 PM.
    Feel free to e-mail me if I forget to respond ;)
    ohsosexybrit@gmail.com


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •