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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T05:13:29+00:00 2026-06-09T05:13:29+00:00

My code works fine in firefox but in Chrome I get an error. It’s

  • 0

My code works fine in firefox but in Chrome I get an error. It’s just grabbing an element and setting the opacity so I’m not sure where I’m going wrong.

  var bot = document.getElementById ("bot");
  var top = document.getElementById ("top");
  top.style.opacity = 0.0;

I get the error “Uncaught TypeError: Cannot set property ‘opacity’ of undefined” for the third line of code and I’m not sure what the problem is. I’ve checked to make sure that the element’s id is ‘top’ and that it’s the only element with that id.

This is the relevant html code

<div class = "banner" id = "bot">
  <div class = "bannerTop" id = "top">
  </div>
</div>

Any help would be appreciated.

  • 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-09T05:13:30+00:00Added an answer on June 9, 2026 at 5:13 am

    Change the name of your global variable to something other than top and it works in Chrome:

    http://jsfiddle.net/jfriend00/y2QQT/

    This is likely because window.top us a read-only variable that already exists.

    You could also put your code into a local function so your var top isn’t a global variable and it should also work then as shown here: http://jsfiddle.net/jfriend00/62uYa/.

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

Sidebar

Related Questions

this code works fine in Firefox, in chrome/internet explorer i get an error in
I have the following CSS code, works fine with Firefox, Chrome but breaks like
ok, this code works just fine in Chrome. But, for some reason it does
My code works on Chrome but not on Firefox... in Firefox... whenever this piece
The following code works fine in firefox but as with many other things, I
i have some javascript roll over code that works fine in firefox but when
This code works fine in Chrome. However, in Firefox, when it hits the GMxhr
In chrome and safari, the following code works fine. in firefox , all platforms,
I have a Firefox 3.6.2 problem (3.5.x works just fine). This is the code:
My code works fine when I call AA.sendRequest() from the console, but not when

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.