Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript
|
Javascript General Javascript discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 30th, 2007, 02:51 AM
Authorized User
 
Join Date: May 2007
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to swifty_programmer
Default Javascript works in IE7 not in FF 2

Hi all,
I'm devloping an AsP.NET 2.0 WebApp.
I added a JavaScript file (js) to one of my pages (ClientRegister...)

I'm debugging in IE7 and there everything works great.
But when i try it in FF I get weird errors.

To give you a ruff draw of the page:

it's an overviewpage with sevral custom made popup windows (like for search or status-view). Now I want that when you hit the "enter" key
that it doesn't do anything except when you're in a textbox of one of the search-poppup, it should be replacing a mouse click on the button 'search'.

In IE7 this model works great, but when I load the page in FF I get following error:

 
Quote:
quote: missing ( before formal parameters
Quote:
[Break on this error] function document.onkeydown()\n
for make the enter key do the same as the button and evrywhere else do nothing I use following javascript-function:

Code:
function document.onkeydown()
{
if(event.keyCode ==13)
    {
    var searchCompanyEl = document.getElementById(CPH_Results + '_tCompanyName');
    var searchUnitByIdEl = document.getElementById(CPH_Results + '_tUnitId');
    var searchUnitByNameEl = document.getElementById(CPH_Results + '_tUnitName');

    switch(event.srcElement)
        {
        case searchCompanyEl :
        document.getElementById(CPH_Results + '_lbCompanySearch').click();       
        break 

        case searchUnitByIdEl :
        document.getElementById(CPH_Results + '_lbSearch').click();
        break

        case searchUnitByNameEl :
        document.getElementById(CPH_Results + '_lbSearch').click();
        break
        }

    event.returnValue = false;
    event.cancel = true;
    }
}
From the moment this error get prompted ALL my javascript gives an undefinied error when called.

Can someone help? I've been looking for like half a day and still nothing. Thx all.

Grtz
 
Old August 30th, 2007, 06:28 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 344
Thanks: 0
Thanked 1 Time in 1 Post
Default

the reason that you are having the issues is that your function definition is incorrect, the function should just be called something like function X and then you should create an event handler to bind that event to the document.onkeydown event. Secondly the EVENT object that you interrogate is only valid in IE so you will have to look at how to handle that in other browsers. check out http://www.washington.edu/webinfo/sn...pt/events.html which addresses both of these issues.
 
Old August 31st, 2007, 02:07 AM
Authorized User
 
Join Date: May 2007
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to swifty_programmer
Default

Hi, thx for the reply.
I actually did that (coupling the event to an eventListener function)
but without any luck.
On the url you gave they say the event object is recognised by following browsers: (IE5 and up, Mozilla, Netscape 6 and up, Safari, Opera, etc.)
And I used the event object just fine before in FF.
Guess I continue trying but I will re-couple the event to a listener.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Works in IE but not in FF sofiacole Pro JSP 1 September 12th, 2007 11:20 PM
IE7 and JavaScript kwilliams Javascript 2 November 6th, 2006 02:33 AM
Javascript Works Fine in Aspx page but... vivek_inos Javascript 0 June 14th, 2006 01:57 AM
Window status works in FF, but not IE...why? msprothero Javascript 2 March 22nd, 2005 10:10 AM
Cross-frame scripting, works in FF but not IE Snib Javascript 4 October 25th, 2004 08:54 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.