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

  • Home
  • SEARCH
  • 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 6358717
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T23:25:27+00:00 2026-05-24T23:25:27+00:00

Apparently the ids for HTML elements get loaded into the global namespace for Javascript

  • 0

Apparently the ids for HTML elements get loaded into the global namespace for Javascript on an HTML page. As such, if I have HTML like:

<p id="mypara">Hello</p>

I can run Javascript like:

mypara.innerText += " world";

which results in the paragraph having “Hello world” as its text in IE9 and Chrome on Windows. This seems like a more convenient way to refer to HTML elements than the standard

document.getElementById("mypara").innerText += " world";

As far as I can tell, the cons seem to be that you can’t give HTML elements ids that are Javascript keywords (doesn’t seem so bad) and your global namespace is more polluted.

Are there any other problems with this approach? Is there any documentation that describes exactly when/how the population of the global namespace is done by browsers? Are there quirks or pitfalls? Has anyone done any browser compatibility testing?

  • 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-24T23:25:28+00:00Added an answer on May 24, 2026 at 11:25 pm

    Early IE introduced the practice of making element ids and names global references to the elements. It was never standardised and was considered a very bad idea.

    Other browsers provided various levels of support for the practice to be compatible with sites written for IE, but generally support was minimal (even hidden to some extent) to discourage its use. Some browsers only supported it in quirks mode or with certain DOCTYPEs.

    It is still considered a very bad idea, do not use it. Use appropriate DOM methods, don’t rely on such browser quirks.

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

Sidebar

Related Questions

Apparently you can't have a Nullable<Rectangle> in Silverlight. I'd like to know the technical
Apparently xrange is faster but I have no idea why it's faster (and no
Apparently I can't move files on different volumes using Directory.Move. I have read that
Apparently some vendors (like Telerik) are working on versions of their controls that do
So we've got a legacy system that tracks places with IDs like Europe/France/Paris, and
Apparently, this call to window.open is not valid under Internet Explorer. The Javascript code
Apparently there is no predefined list available in .net. I'd like to use a
So apparently the support you get from Varien when you purchase the Enterprise Edition
I have ArrayList<String> ids = ArrayList<String>(); What would be the cleanest way to make
Apparently WIne doesn't support 16bit DOS apps. Anyone know how to Get MASM intel-style

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.