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 5 of 5

Thread: error in FF

  1. #1
    New Coder
    Join Date
    Feb 2009
    Posts
    26
    Thanks
    0
    Thanked 0 Times in 0 Posts

    error in FF

    i am using
    var evt = evt || window.event; // event object
    var targ = evt.target || window.event.srcElement; // event target

    but still getting error in FF
    Error: evt is undefined
    Line: 101

  • #2
    Senior Coder
    Join Date
    Mar 2005
    Location
    Portsmouth UK
    Posts
    4,513
    Thanks
    3
    Thanked 504 Times in 491 Posts
    Code:
     var evt=window.event||arguments.callee.caller.arguments[0];
     var obj=window.event?evt.srcElement:evt.target;
    Vic

    God Loves You and will never love you less.

    http://www.vicsjavascripts.org/Home.htm

    If my post has been useful please donate to http://www.operationsmile.org.uk/

  • #3
    Senior Coder A1ien51's Avatar
    Join Date
    Jun 2002
    Location
    Between DC and Baltimore In a Cave
    Posts
    2,717
    Thanks
    1
    Thanked 94 Times in 88 Posts
    function foo(evt){ <-- do you have evt here?

    Eric
    Tech Author [Ajax In Action, JavaScript: Visual Blueprint]

  • #4
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,036
    Thanks
    203
    Thanked 2,539 Times in 2,517 Posts
    Code:
    <script type = "text/Javascript">   
    
    function handleKeyPress(evt) {   
    var x = (window.event)?event.keyCode:evt.which;   
    alert (x);   
    return true;   
     }   
     document.onkeydown= handleKeyPress   
    </script>

  • #5
    New Coder
    Join Date
    May 2006
    Posts
    62
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by svibuk View Post
    i am using
    var evt = evt || window.event; // event object
    var targ = evt.target || window.event.srcElement; // event target

    but still getting error in FF
    Error: evt is undefined
    Line: 101
    If you are already passing evt into the function, then:

    Code:
    var evt = evt || window.event; // event object
    would make evt null.

    The "var evt" makes "evt" null.

    So you need:

    Code:
    evt = evt || window.event; // event object
    this make sure evt is not set to null before being evaluated after the "=".

    Notice that "var" is removed.
    Fiji Web Design - where i do Joomla Web Design
    Bucabay.com - My blog


  •  

    Posting Permissions

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