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 6048991
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T07:31:31+00:00 2026-05-23T07:31:31+00:00

I am currently facing an error in JavaScript. The code is given below function

  • 0

I am currently facing an error in JavaScript. The code is given below

function loader() {
    size = window.innerWidth;
    size = size - 300;
    mainj = document.getElementById('main1');
    mainj.style.left = size.toString() + 'px';
    submainj = document.getElementById('submain1');
    submainj.style.left = size.toString() + 'px';
    size = mainj.style.top + 26;
    document.getElementById('submain1').style.top = size.toString() + 'px';
}
onload = loader();

The error comes only in Internet Explorer and the code works perfectly in Firefox. The error shows is in the fifth line, the error being

Message: Object required
Line: 34
Char: 1
Code: 0
URI: http://localhost/home.php

Line 34 is the 5th line given in the code – ‘mainj.style.left…..’
How can I fix this problem?

  • 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-05-23T07:31:32+00:00Added an answer on May 23, 2026 at 7:31 am

    This is the offending line:

    size=window.innerWidth-300;
    

    Internet Explorer doesn’t have a concept of inner width on window, as far as I know. The following code is a decent cross-browser implementation, similar to something you would see in a library. There are corresponding innerHeight and offsetHeight properties if you needed height as well.

    var size = 0;
    if(window.innerWidth) {
        size = window.innerWidth;
    } else if (document.documentElement && document.documentElement.offsetWidth) {
        size = document.documentElement.offsetWidth;
    } else if (document.body && document.body.offsetWidth) {
        size = document.body.offsetWidth;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Good Morning everyone I'm currently facing a segfault at random on a little piece
In an site I'm currently writing, I'm facing a strange, mind-boggling behaviour: after seconds
I am currently facing a scenario that I am unsure what is the best
I am currently facing a problem. How to get the latest selected value from
I am currently using PHP 5 with a MysSQL database with 2 tables. So
I'm currently messing with google's apis using ajax trough jquery library. In order to
I am working on a basic app that has a public facing form (for
Recently deployed my web app on Windows Server2008, IIS7 (with Office installed). After chasing
Is BlazeDS 4 work with Google App Engine. I'm using BlazeDS 3.2.0 and getting
While working on a vb.net application, in which exceptions were handled poorly. It was

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.