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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:34:32+00:00 2026-05-28T05:34:32+00:00

Hello I am sorry to bother you with such a simple question but this

  • 0

Hello I am sorry to bother you with such a simple question but this bit of code, I literally could not find anything wrong with it, but none of the alerts even trigger so I know that init isn’t even been passed to window.onload. Here is the code:

window.onload()=init;
alert("The file has been linked to.");
function init(){
    alert("Init has been loaded");
var button = document.getElementById("myButton");
    button.onclick = handleButtonClick; 
 }

function handleButtonClick()
{
    alert("button has been clicked");
    var target = document.getElementById("target");
    var image = document.createElement("<img />");
    image.innerHTML = "<img src=../Images/banner_test.jpg alt=Banner height=42          width=42 />" ;
target.appendChild(image);
 }

The JS is in a external js file I’ve linked to with:

<script type="text/javascript" src="../JS/Experiment.js" > </script>

Have I misspelt something or forgotten a parameter because as I’ve said none of the alarms will activate, no use talking about creating a new <img /> and adding it.

The HTML isn’t a problem I’ve tried a simple alert() with inline <script> and it works but I need this to be in a external file.

  • 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-28T05:34:33+00:00Added an answer on May 28, 2026 at 5:34 am

    window.onload is not a method, drop the parens ()

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

Sidebar

Related Questions

Sorry as the question is bit lengthy. I have this string Hello how are
Hello yeah I'm asking this question a second time, sorry about that but I
Hello guys and sorry for such a long question, but... I have a C#
Hello everyone :) I'm sorry for the long code listing, but I'm not sure
Hello! I'm not even sure if this is possible, but hopefully it is in
hello there and sorry for the stupid question but i think i might be
Hello and sorry I've seen alot of problems like this but no direct answer
Question: Hello All, Sorry that this is kind of a noob question. I just
sorry for asking this question again but i didnt get much help on the
Hello for all people... Sorry for my english, but speak spanish... In this week,

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.