Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jul 2018
    Thanked 0 Times in 0 Posts

    Javascript in IE Compatibity mode :Object doesn't support this property or method

    Hello, we have been given the task to convert an older website that has vbscript to javascript . Since this is happening in stages the users still use IE set with Compatibility Mode on. We also have the goal to get this working in Chrome.

    The problem is here... we get "Object doesn't support this property or method" ON this line document.form1.txtDobday = ""; This works fine in when Comp Mode is OFF and it works in Chrome.

    Can someone please shed some light???!!!

    if(document.form1.txtBusinessDebtor.value == ""){
    document.form1.txtDobday = "";
    document.form1.txtMonth = "";
    document.form1.txtDOByear = "";

    this is the html for the textbox

    <input type="text" name="txtDobday" id="txtDobday" size="3" maxlength="2" class="boldregulartext">

  2. #2
    Senior Coder deathshadow's Avatar
    Join Date
    Feb 2016
    Keene, NH
    Thanked 463 Times in 451 Posts
    Uhm, you can't set the input to "", you can set the input's VALUE to ""...

    document.form1.txtDobday.value = "";

    MIGHT work, but beware that accessing forms and form elements by 'name' is an outmoded and unreliable way of accessing elements on a page that PROBABLY should have been kicked to the curb the day we stopped caring about Netscape 4. I've seen it bite too many codebases in the backside the past decade and a half, and avoid using it whenever possible. (Much like how I won't use the table methods of addRow or addcells since you have no control over thead vs. tbody or th, and instead will document.createElement)

    I would put serious thought to switching to doing a getElementById on them instead (since you appear to have ID's like a good little doobie), or even walking the DOM or grabbing a collection if possible. (I'd have to see the full markup to say for sure)

    document.getElementById('txtDobday') = '';

    Would probably be more reliable in the modern world.

    I'd probably also drag that markup kicking and screaming into THIS century, since class="boldregulartext" is pretty derp. Might as well go back to using HTML 3.2 at that point.
    Last edited by deathshadow; Jul 6th, 2018 at 09:22 PM.
    “There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies and the other way is to make it so complicated that there are no obvious deficiencies.” – C.A.R. Hoare, The 1980 ACM Turing Award Lecture


Tags for this Thread

Posting Permissions

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