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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T10:52:22+00:00 2026-05-12T10:52:22+00:00

i want someone to include a JS file of me which does something neat.

  • 0

i want someone to include a JS file of me which does something neat. I thought i put it up just like Google: you put a script tag in your source and the google js takes care of everything.
in my php file is this:

echo '<script type="text/javascript"
src="http://www.site.com/gadget.js">
</script>';

i that gadget.js, i write a span:

document.write('<span id="GadgetPicture>');
document.write('</span>');
window.setTimeout('refreshImage();', 2000);

in the refreshImage function, i want to reference my span:

document.getElementById("GadgetPicture");

But it gives me null…
Does anybody know why?

also, document.getElementById("body") also give null.

Michel

  • 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-12T10:52:22+00:00Added an answer on May 12, 2026 at 10:52 am

    For one your missing the quote in the <span> like everyone has said, and you should not be using the document.write to create new elements on the page as Greg said use createElement and appendElement like;

    var span = document.createElement('span');
    span.id = 'GadgetPicture';
    
    document.appendChild(span);
    

    You could also use jQuery and the HTML helper http://docs.jquery.com/Attributes/html#val

    Also in your setTimeout method you should use it like;

    setTimeout(function() { refreshImage(); }, 2000);
    

    or

    setTimeout(refreshImage, 2000);
    

    Declaring a string will cause Javascript to use eval on the contents.

    You can get the body of the document with getElementsByTagName as the body tag is not something that usually has an ID.

    document.getElementsByTagName("body")[0]
    

    You can safely assume that the first found element will be the body your after, as a page with multiple would be invalid HTML.

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

Sidebar

Related Questions

I'd like to distribute a set of build variables (which someone should append to
I'm producing a hex file to run on an ARM processor which I want
I have helper class which contain different methods. I dо not want to include
I want that everytime someone wants to checkout the project from SVN he/she will
Could someone please explain when would I want to use delegation instead of inheritance?
When someone visits my page I want them to be rerouted to the login
Can someone help me on how to setup such a result: Want to know
I want to ask how can someone read keystrokes while in a html page
I want to add a custom message once someone saves a specific content-type telling
I want my program to get notification each time someone makes a post to

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.