SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Evangelist Tapan's Avatar
    Join Date
    May 2005
    Location
    India
    Posts
    563
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Angry Javascript not working in FireFox

    Hi,

    I have made a javascript which is working absolutely fine in IE and Opera. But in FireFox its dead. There's no error messages, nothing at all. Can anyone tell me whats wrong with it ?

    My javascript is doing a ajax call and enabling / disabling buttons on result of that ajax call. Thats it.

    I have tried to keep the javascript as simple as possible and it works great in IE and Opera but FireFox simply does'nt do anything.

    Can anyone tell me if FireFox supports ajax etc. ?

    Thanks.

  2. #2
    SitePoint Wizard bronze trophy Kailash Badu's Avatar
    Join Date
    Nov 2005
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    show us the code buddy, will you? and point out the part that you think isn't working.

  3. #3
    SitePoint Evangelist Tapan's Avatar
    Join Date
    May 2005
    Location
    India
    Posts
    563
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    Please goto http://www.avissoftware.com/myce/

    Above url works in IE and Opera but not in FireFox. There's no error etc. coming up whatsoever.

    Thanks.

  4. #4
    SitePoint Wizard bronze trophy Kailash Badu's Avatar
    Join Date
    Nov 2005
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Both of the buttons don't seem to have 'id' attribute set.
    For the first button put
    Code HTML:
    <input type="submit" id="btnRegister" name="btnRegister" value="Register and Host" style="width: 200" disabled="true">

    For the second button:
    Code HTML:
    <input type="submit" id="btnSelfMgmt" name="btnSelfMgmt" value="Host this Domain" style="width: 200" disabled="true">

  5. #5
    SitePoint Evangelist Tapan's Avatar
    Join Date
    May 2005
    Location
    India
    Posts
    563
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    It has started working thanks. You're a genius. I wasted so much time figuring this out. One small tiny issue now. I have put code in the text box so that if a user types the domain and presses enter key then the check buttons gets pressed automatically. This is not working in FireFox. Can you help in this ?

    Thanks.

  6. #6
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,682
    Mentioned
    99 Post(s)
    Tagged
    4 Thread(s)
    The script code you have is directly inline with the html. Would you put css inline on your page? No? Keep the HTML, CSS and Javascript separate and things will be better for you.

    I'll take you through how they should be, so that we can move forward to a solution.

    Code html4strict:
    <input type="text" name="domain" value="">
    <input type="button" id="btnCheck" name="btnCheck" value="Check">

    and place this code at the end of the body just before the </body>, or use some other method to run the script after the page elements are available.

    Code javascript:
    var domain = document.getElementsByName('frmCheckDom')[0];
    var btnCheck = document.getElementsByName('btnCheck')[0];
    domain.onchange = ResetTakenOrNot;
    domain.onkeypress = function () {
        if (window.event && window.event.keyCode == 13) {
            btnCheck.focus();
            btnCheck.click();
            return false;
        }
    };
    btnCheck.onclick = function () {
        ResetTakenOrNot;
        ChangeToWait();
        sndUserCheck(domain.value);
    };

    That is how you currently have those parts scripted.

    Now the trouble is with the domain.onkeypress event. Currently it's designed to work only on IE. Here is the cross-browser way to handle such events.

    Code javascript:
    domain.onkeypress = function (evt) {
        evt = evt || window.event;
        var keyCode = evt.charCode || evt.keyCode;
    	if (keyCode === 13) {
    		btnCheck.focus();
    		btnCheck.click();
    		return false;
    	}
    };

    Note: === checks that they're equal. == only checks if they're somewhat similar
    http://developer.mozilla.org/en/docs...ison_Operators

    See http://www.quirksmode.org/js/keys.html for great details on reliably detecting keystrokes.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript


Bookmarks

Posting Permissions

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