CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: return false

  1. #1
    Join Date
    Sep 1999
    Location
    Leeds U.K. (Proud to be Sheffield Born)
    Posts
    202

    Unhappy return false

    I have oncontextmenu="return false;" and oncontextmenu="javascript:return false;" as attributes (it's a <TH> tag, incidentally, but I don't suppose it matters), and the resultant behaviour is satisfactory. However, when I have oncontextmenu="javascriptoThing();" along with
    function doThing(){
    return false;
    }
    I still get the context menu popping up.
    Why is this, and how can I prevent it?

    thanks,

    S. Monkey (Mr)

  2. #2
    Join Date
    Jan 2002
    Location
    Helsinki, Finland
    Posts
    99
    The problem
    (CORRECT) :
    <elem onevent="return false;" />

    (INCORRECT [where fooBar() returns false]) :
    <elem onevent="fooBar();" />


    How browser parses
    (CORRECT example [look above]):
    <elem onevent="return false;" />

    (INCORRECT example [look above]):
    <elem onevent="false;" />


    The solution
    (INCORRECT example fixed to CORRECT):
    <elem onevent="return fooBar();" />


    Brief : you have to return the return value of the function to the object (element/tag in HTML).
    Zvona - First aid for client-side web design

  3. #3
    Join Date
    May 2002
    Location
    India
    Posts
    143

    context menu

    try this

    oncontextmenu="javascriptoThing();return false;"

    on right click first call is to your function and the return false is for window's own context menu.

    hope it works.. :-)
    Anupam.

  4. #4
    Join Date
    Sep 1999
    Location
    Leeds U.K. (Proud to be Sheffield Born)
    Posts
    202

    Hooray.

    Thankyou, Zvona.

    Good point, well made, works for me. My script is no longer Fubar'd.

    Cheers muchly,

    Surrendermonkey.
    Last edited by Surrendermonkey; June 10th, 2002 at 04:15 AM.

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured