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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T05:02:02+00:00 2026-06-18T05:02:02+00:00

My HTML file <!DOCTYPE HTML> <html lang=en-US> <head> <meta charset=UTF-8> <title></title> </head> <body> <p>Hello

  • 0

My HTML file

<!DOCTYPE HTML>
<html lang="en-US">
<head>
    <meta charset="UTF-8">
    <title></title>
</head>
<body>
    <p>Hello World</p>
    <script type="text/javascript" src="hello.js"></script>
</body>
</html>

My javascript file

var button = document.createElement("button");
button.id = "test";
button.innerHTML = "Test";
button.addEventListener("click", function() {
    alert("hello");
});
var body = document.body;
body.appendChild(button);

I don’t understand why when I click Test button, console of Chrome displays error “Uncaught Error: INDEX_SIZE_ERR: DOM Exception 1” . But I realize that error appears only if I run it on localhost (I use apache of xampp as localhost) . If I run as normal file:// , it successes without any error

  • 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-18T05:02:04+00:00Added an answer on June 18, 2026 at 5:02 am

    It works fine for me….

    But any ways please use window.onload function to do any stuff from javascript.

    So do something like this

       window.onload = function(){
            var button = document.createElement("button");
            button.id = "test";
            button.innerHTML = "Test";
            button.addEventListener("click", function() {
                alert("hello");
            });
            var body = document.body;
            body.appendChild(button);   
               }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

<!DOCTYPE HTML> <html lang=en-US> <head> <meta charset=UTF-8> <title></title> <script type=text/javascript src=http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js></script> <script type=text/javascript> $(function(){
I have a index.html file with following syntax <!DOCTYPE html> <html> <head> <meta charset=utf-8>
this is a simple html file: <!DOCTYPE html> <html> <head> <title>Test Uploading Func.</title> <script
HTML file ... <!DOCTYPE html PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN http://www.w3.org/TR/html4/loose.dtd> <html> <head> <meta
So I have this simple html file <!DOCTYPE HTML> <html manifest=cache.manifest><head> <meta name=apple-mobile-web-app-capable content=yes>
Given the following HTML file: <!DOCTYPE html5> <html> <head> <script src=http://ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js type=text/javascript></script> <script type=text/javascript>
If I have the html file: <!doctype html> <html> <head></head> <body> <!-- Begin -->
I have the code in my html file <!doctype html> <html ng-app=slider> <head> <script
Say I have this in a .jade file doctype 5 html head title= title
In my HTML file, I have: <html><head> <style>html{width: 320px; } body {padding: 0; margin:

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.