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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T11:42:09+00:00 2026-06-18T11:42:09+00:00

I created two JavaScript functions. var a, b; function changeTo(a, b) { document.getElementById(a).className =

  • 0

I created two JavaScript functions.

var a, b;

function changeTo(a, b) {
    document.getElementById(a).className = 'editborder';
    document.getElementById(b).className = 'editborder';
}
function changeToo(a, b) {
    document.getElementById(a).className = 'editborder_';
    document.getElementById(b).className = 'editborder_';
}

They are called by the <asp:LinkButton> with one argument:

<asp:LinkButton ID="LinkButton7" runat="server" 
    onMouseover="changeTo('div_master');" 
    onMouseout="changeToo('div_master');" 
    Text="Edit Bg Color" CommandArgument="0" OnClick="lnkchangebg_click">
</asp:LinkButton>

It works fine in Chrome, but in IE6 it causes the following error:

error ‘document.getelementbyid(…)’ is null or not an object

How is this caused and how can I solve it?

  • 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-18T11:42:10+00:00Added an answer on June 18, 2026 at 11:42 am

    Your function gets two required parameters and you’re passing just one.

    You could refactor your functions so the second parameter wont be required, like this:

    function changeToo(a, b) {
        document.getElementById(a).className = 'editborder_';
        if (typeof b !== "undefined") {
            document.getElementById(b).className = 'editborder_';
        }
    }
    

    It also seems a bit clunky to use two different functions that seem to do almost exactly the same. If you would take it one step further, you could refactor your whole code to this:

    function changeClass(a, strClass) {
        if (typeof a === "string") {
            document.getElementById(a).className = strClass;
        } else if (typeof a === "object" && a.length > 0) {
            for (var id in a) {
                if (a.hasOwnProperty(id)) {
                    document.getElementById(id).className = strClass;
                }
            }
        } else {
            throw new Error("Invalid argument supplied in changeClass().");
        }
    }
    

    Now you can do:

    <asp:LinkButton ID="LinkButton7" runat="server" 
        onMouseover="changeClass('div_master', 'editborder');" 
        onMouseout="changeClass('div_master', 'editborder_');" 
        Text="Edit Bg Color" CommandArgument="0" OnClick="lnkchangebg_click">
    </asp:LinkButton>
    

    Or even:

    <asp:LinkButton ID="LinkButton7" runat="server" 
        onMouseover="changeClass(['div_master', 'anotherElementId'], 'editborder');" 
        onMouseout="changeClass(['div_master', 'anotherElementId'], 'editborder_');" 
        Text="Edit Bg Color" CommandArgument="0" OnClick="lnkchangebg_click">
    </asp:LinkButton>
    

    If that still doesn’t fix your problem, Louis Lazaris wrote an excellent post about avoiding problems with .getElementById() in Internet Explorer.

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

Sidebar

Related Questions

I've created a 'class' in javascript called QuoteProductService(), see below. I've added two functions
These two javascript functions work perfectly on unaltered dom elements. However the delete_route function
I have created two JavaScript files. One file is "validators.js" and the other is
I created two dropdpwn calendar in my form with these codes: <script type=text/javascript src=http://code.jquery.com/jquery-latest.js></script>
I have created tab style interface using css and javascript with only two tabs
First time asking a question here. I have two simple Javascript functions that 1.
I am using a JavaScript function and some jQuery to perform two actions on
I created of social network buttons where there is a javascript function that create
I have created two canvases in a div using Javascript. I have another div
For using a static variable in javascript functions I found out two ways, using

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.