SitePoint Sponsor

User Tag List

Results 1 to 12 of 12
  1. #1
    SitePoint Wizard westmich's Avatar
    Join Date
    Mar 2000
    Location
    Muskegon, MI
    Posts
    2,328
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Firefox/Safari Issues

    I've been working with Javasrcipt on Firefox (a mozilla off-shoot but very similar to Safari on Mac) but can't seem to find any kind of debugging window. The script either works or nothing happens.

    Specifically, I am trying to compare dates. I had a simple function that I know works in IE doesn't work correctly on Firefox. I found a much more elaborate script on another site that should work around browser issues and got the same result.
    Westmich
    Smart Web Solutions for Smart Clients
    http://www.mindscapecreative.com

  2. #2
    He's No Good To Me Dead silver trophybronze trophy stymiee's Avatar
    Join Date
    Feb 2003
    Location
    Slave I
    Posts
    23,424
    Mentioned
    2 Post(s)
    Tagged
    1 Thread(s)
    The debugging window should be under the Tools menu. If not, you didn't select developer tools during your install. Try to reinstall and you should be fine. Well, at least as far as the debugging goes.

  3. #3
    SitePoint Wizard silver trophy
    Join Date
    May 2003
    Posts
    1,843
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Firefox (Gecko rendering engine) and Safari (KHTML rendering engine) are actually pretty different. Camino (formerly Chimera) is actually the Mac equivalent. Firefox has a pretty decent onboard-console for debugging, available under the Tools menu.
    ::: certified wild guess :::

  4. #4
    SitePoint Wizard westmich's Avatar
    Join Date
    Mar 2000
    Location
    Muskegon, MI
    Posts
    2,328
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Didn't see it - thanks!
    Westmich
    Smart Web Solutions for Smart Clients
    http://www.mindscapecreative.com

  5. #5
    SitePoint Wizard westmich's Avatar
    Join Date
    Mar 2000
    Location
    Muskegon, MI
    Posts
    2,328
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    OK - now that I found the debugging window, I am even more confused. I keep getting undefined errors. I've even tried using common, built in functions like getSeconds() or getTime() and get the same undefined error.

    Does this have it's own Javascript flavor?
    Westmich
    Smart Web Solutions for Smart Clients
    http://www.mindscapecreative.com

  6. #6
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,235
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by westmich
    OK - now that I found the debugging window, I am even more confused. I keep getting undefined errors. I've even tried using common, built in functions like getSeconds() or getTime() and get the same undefined error.

    Does this have it's own Javascript flavor?
    Firefox (and Safari) just support what's in the W3C DOM standard, and a few things outside of the standard (mostly for compatibility with IE-only code). Perhaps your date object isn't created correctly; do you have some code we can dissect?

  7. #7
    SitePoint Addict
    Join Date
    May 2000
    Posts
    313
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here is a link to a developer site for Safari. Perhaps it will help:
    http://developer.apple.com/internet/safari.html

    And another:
    http://developer.apple.com/internet/javascript/

  8. #8
    SitePoint Wizard westmich's Avatar
    Join Date
    Mar 2000
    Location
    Muskegon, MI
    Posts
    2,328
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here is the code I've gotten to work. Firefox seems to need a date type variable created from the Date() constructer.
    Code:
    var dOld = new Date('6/11/2004');
    var dCurrent = new Date('6/3/2004');
    if(dCurrent > dOld) {
     alert('Current is greater');
    } else {
     alert('Old is greater');
    }
    The only problem is that I can't write the dates in there, they need to come from user input. I tried this without any luck.
    Code:
    var dOld = new Date(document.getElementById('txtWODueDate').value);
     var dCurrent = new Date(document.getElementById('txtStartDate').value);
    Westmich
    Smart Web Solutions for Smart Clients
    http://www.mindscapecreative.com

  9. #9
    SitePoint Wizard westmich's Avatar
    Join Date
    Mar 2000
    Location
    Muskegon, MI
    Posts
    2,328
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Is there any other way to get the dates in?
    Westmich
    Smart Web Solutions for Smart Clients
    http://www.mindscapecreative.com

  10. #10
    SitePoint Wizard silver trophy
    Join Date
    May 2003
    Posts
    1,843
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ...as VG said:
    do you have some code we can dissect?


    Need to see the entire logic here (within reason)...
    ::: certified wild guess :::

  11. #11
    SitePoint Wizard westmich's Avatar
    Join Date
    Mar 2000
    Location
    Muskegon, MI
    Posts
    2,328
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The code above is the code - thats all there is to it. Here it is again -

    Code:
    //works
    var dOld = new Date('6/11/2004');
    var dCurrent = new Date('6/3/2004');
    if(dCurrent > dOld) {
     alert('Current is greater');
    } else {
     alert('Old is greater');
    }
    
     
    
    //doesn't work
    var dOld = new Date(document.getElementById('txtWODueDate').value);
    var dCurrent = new Date(document.getElementById('txtStartDate').value);
    if(dCurrent > dOld) { 
     alert('Current is greater');
    } else { 
     alert('Old is greater');
    }
    Westmich
    Smart Web Solutions for Smart Clients
    http://www.mindscapecreative.com

  12. #12
    JavaScript Guru (Big Ego) Arielladog's Avatar
    Join Date
    Jul 1999
    Location
    SC, USA
    Posts
    390
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey westmich,

    I created a simple example, and you're code worked perfectly:

    Code:
    <html><body><script language="javascript" type="text/javascript">
    function doIt(){
    var dOld = new Date(document.getElementById('txtWODueDate').value);
    var dCurrent = new Date(document.getElementById('txtStartDate').value);
    if(dCurrent > dOld) { 
     alert('Current is greater');
    } else { 
     alert('Old is greater');
    }
    }
    </script>
    <form>
    Old: <input id="txtWODueDate" type="text"><br />
    Current: <input id="txtStartDate" type="text"><br />
    <button onclick="doIt()">CLick me</button></form>
    </body>
    </html>
    The problem you might be running into is you're calling document.getElementById() before the whole document has finished loading, so it's returning nothing.

    The above is just speculation, but without more code, that's all I got

    aDog


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
  •