Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8113009
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T02:41:21+00:00 2026-06-06T02:41:21+00:00

The following line of code causes a JScript object expected error in IE: hideElements.apply(window,

  • 0

The following line of code causes a “JScript object expected” error in IE:

hideElements.apply(window, elements);

According to IE, the ‘expected JScript object’ refers to hideElements, which is a function that takes any number of HTML objects as arguments and hide them.

Concretely, I retrieve an array of HTML objects via a call to getElementsByTagName, and I would like to pass this array as a list of arguments to the function hideElements. The JS function apply() is exactly what I need in that case. I know I could surely write my code differently, but since this works perfectly on Firefox and Chrome, and is technically correct, I’d really like to know why IE gets stuck there.

I’ve determined that, when the line is executed:

  • window is not null and of type Window;
  • elements is not null and of type HTMLCollection; and
  • hideElements is a fully functional JS function (that works perfectly on its own and that is fully loaded when the code above is executed).
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T02:41:23+00:00Added an answer on June 6, 2026 at 2:41 am

    getElementsByTagName returns a nodeList. apply expects the second argument to be an array. If you convert elements to a real array (using a loop), it should work.

    Note: In IE<9, it’s not possible to use Array.prototype.slice.call(elements) for that, so a loop is the safest way to create an array, like:

    function nodeList2Array(nodes){
      var arr = [];
      for (var i=1; i<nodes.length;(i+=1)){
        arr.push(nodes[i]);
      }
      return arr;
    }
    

    now: hideElements.apply(window, nodeList2Array(elements)); should work.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The following code causes a memory error in the insert_edge function (in the line
The following line of code causes my program to break in a very strange
The following code is causing me some problems. The third line causes a program
The following line of code generates the compile time error (PE19) There is no
I have the following line of code: var html = ...; $(#id_name).append(html).fadeIn(slow); This causes
The following code causes an error: <c:set var=test value=test1/> <% String resp = abc;
The following line of code is causing me an Exception using (new INVU.API.CallContextStore()) {
Using the following line of code in my project I am able to programmatically
I have the following line of code to add a To address to a
I thought the following line of code should work fine: $(.1).attr('href', '#Home'); Right? But

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.