SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Wizard gold trophysilver trophybronze trophy dc dalton's Avatar
    Join Date
    Nov 2004
    Location
    Right behind you, watching, always watching.
    Posts
    5,431
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Stupid IE 'object required' error ... only on certain machines, makes NO sense

    I have a script that is throwing an 'object required' error but only on the customer's machines (in IE 7 and 8) ... on my machine in IE 8 it works fine, on my wife's machine (IE 7) it works fine, on my laptop (IE 6) it works fine ... and it works in EVERY other browser out there (FF, Opera, Safari, Flock)...

    The guy is making me crazy with this dumb thing and I am saying it has to be something on his machine because I see no problems, nor get any errors on any of my machines. Here is the code:

    Code JavaScript:
    function show_preview()	{
    	window.open("c_pop.php?to=" + document.getElementById('livesearch').value + "&sub=" + document.getElementById('subject').value + "&mess= " + document.getElementById('message').value, "Link", "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=450,height=400,left=30,top=80");
    	}

    The error from IE is simple:

    "Object required" line 2 character 2 - the window.open is line 2

    Anyone able to help me get this guy out of my hair cause I give up!

  2. #2
    SitePoint Zealot
    Join Date
    Jun 2008
    Posts
    126
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That one machine might be configured with customized Internet Explorer security settings that are more restrictive than the other machines.

  3. #3
    SitePoint Wizard gold trophysilver trophybronze trophy dc dalton's Avatar
    Join Date
    Nov 2004
    Location
    Right behind you, watching, always watching.
    Posts
    5,431
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by SteveWh View Post
    That one machine might be configured with customized Internet Explorer security settings that are more restrictive than the other machines.
    He said he shut off all the security settings. I also found some info about Vista screwing up things but haven't heard back from him on whether he is using it.

  4. #4
    SitePoint Wizard gold trophysilver trophybronze trophy dc dalton's Avatar
    Join Date
    Nov 2004
    Location
    Right behind you, watching, always watching.
    Posts
    5,431
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sure enough, he is using Vista ... UGH

  5. #5
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2008
    Posts
    5,757
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Break your code up into many lines so the line number in the error message is more specific.

    Instead of assuming an object has a property or method, test it before using it.
    Code:
    if (window.open) {
        window.open(...);
    }
    var elem = document.getElementById('livesearch');
    // elem could be null. trying to use a property of something that is null will throw an error
    if (elem) {
        // elem is not null, we can use the property
        elem.value;
    }
    Be aware that an element with the given id needs to exist at the time that script runs for getElementById() to be able to grab it.

  6. #6
    SitePoint Wizard gold trophysilver trophybronze trophy dc dalton's Avatar
    Join Date
    Nov 2004
    Location
    Right behind you, watching, always watching.
    Posts
    5,431
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by crmalibu View Post
    Break your code up into many lines so the line number in the error message is more specific.

    Instead of assuming an object has a property or method, test it before using it.
    Code:
    if (window.open) {
        window.open(...);
    }
    var elem = document.getElementById('livesearch');
    // elem could be null. trying to use a property of something that is null will throw an error
    if (elem) {
        // elem is not null, we can use the property
        elem.value;
    }
    Be aware that an element with the given id needs to exist at the time that script runs for getElementById() to be able to grab it.
    Already tested the elements and they are fine

  7. #7
    SitePoint Zealot
    Join Date
    Jun 2008
    Posts
    126
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    He said he shut off all the security settings
    Not sure what he could have meant by that.

    I was referring to the IE security settings at Tools > Internet Options > Security where you set the config settings for the Internet Zone, Trusted Sites, etc. I'm not aware of any ability to "shut those off".

    Every website belongs to one of the zones, and each zone has several dozen possible customizable security settings. Some relate to script-opened windows and opening windows with particular characteristics.

    If he has something disabled that your code tries to do, then the code won't work.

    In addition, JavaScript ("active scripting") might be disabled in his Internet Zone. His own site might be in Trusted Sites, where JS is enabled. If your script depends on any scripts called from outside sites, those sites are likely in the Internet Zone. Those scripts won't run, and thus your script will crash because the objects it needs weren't created. In other words, when a user is using the IE Zones to control scripts, all the sites that pieces of scripting come from must be in Trusted Sites; otherwise some of the pieces won't run, which could crash the others.

  8. #8
    SitePoint Evangelist
    Join Date
    Mar 2006
    Location
    Sweden
    Posts
    451
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by dc dalton View Post
    Already tested the elements and they are fine
    Have you tested yourself, or has the client tested it? The only things in that code that can go wrong are the document.getElementById and window calls. Try this code instead:

    Code JavaScript:
    function show_preview() {
      var ids = ['livesearch', 'subject', 'message'];
      for(var i = 0; i < ids.length; i++) {
        var id = ids[i]
        this[id] = document.getElementById(id);
        if(!this[id]) {
          this[id] = '';
          // Might want to do some error handling here, since the element doesn't exist
        } else {
          this[id] = this[id].value;
        }
      }
      var url = "c_pop.php?to="
              + livesearch
              + "&sub="
              + subject
              + "&mess="
              + message;
      window.open(url, "Link", "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=450,height=400,left=30,top=80");
    }


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
  •