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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T03:53:28+00:00 2026-05-23T03:53:28+00:00

I am a javascript noob and I need help with this problem ! On

  • 0

I am a javascript noob and I need help with this problem !

On a specific condition a function is called and when it is called , I want an image to be displayed ! How do I do that ? this is not working!

<script type="text/javascript">
function _enabled() {
document.write("<img border="0" src="http://4.bp.blogspot.com/-C4vvMEB9MyI/TfW0lduV2NI/AAAAAAAAAZc/N7HL1pUusGw/s1600/some image.png" />");
}

var r =true;
</script>

This is not working , I get this error

Error: missing ) after argument list
Source File: file:///C:/Users/Gowtham/Desktop/new%20%202.html
Line: 5, Column: 33
Source Code:
document.write("<img border="0" src="http://4.bp.blogspot.com/-C4vvMEB9MyI/TfW0lduV2NI/AAAAAAAAAZc/N7HL1pUusGw/s1600/sjs.png" />"); 
  • 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-23T03:53:28+00:00Added an answer on May 23, 2026 at 3:53 am

    The syntax error is that you’re using double quotes for your document.write string literal, but you’ve also used a double quotes your HTML attributes:

    document.write("<img border="0" src="http://4.bp.blogspot.com/-C4vvMEB9MyI/TfW0lduV2NI/AAAAAAAAAZc/N7HL1pUusGw/s1600/some image.png" />");
    //                          ^--- here and other places
    

    That double quote ends the string literal, so you get a syntax error. You’d want to escape that with a backslash, or use JavaScript’s handy feature where you can use single quotes around string literals.

    But that alone isn’t going to solve the problem. If you call document.write after the main parsing of the page is finished, you’re going to completely erase the page and replace it with new content.

    To display an image after the main parsing of the page is complete, you create a new img element via the DOM document.createElement function and then append it to the element in which you want it to appear. For instance, this code puts a new image at the end of the document:

    function addTheImage() {
        var img = document.createElement('img');
        img.src = "http://....";
        document.body.appendChild(img);
    }
    

    To add to another element, rather than the end of body, you just need to get a reference to the element. There are various ways to do that, including document.getElementById to look it up by its id value, document.getElementsByTagName to look up all elements with a given tag, etc. Some browsers offer very rich methods like querySelectorAll that let you use CSS selectors, but not all do yet. (Many JavaScript libraries like jQuery, Prototype, YUI, Closure, or any of several others plug that gap for you, though, and offer other handy utility features, and features smoothing over browser inconsistencies and outright browser bugs.)

    More about the dom:

    • The DOM2 Core specification (widely supported by major browsers)
    • The DOM2 HTML specification (DOM stuff specific to HTML, also fairly widely supported)
    • The DOM3 Core specificiation (less widely supported, but things are improving)
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Javascript noob here (I'm assuming I will need Javascript to solve this). I need
I am a Javascript noob and I need help adding a codeblock after a
Little help for a javascript noob please... I have this in a .js file
I'm a complete JavaScript noob. I am using this right now: $(function() { $(#tabs).tabs({
This is probably a noob question, but how I've implemented the appendTo() function below
I am a real noob when it comes to javascript/ajax, so any help will
I'm noob to JavaScript and want to use Prototype JS Framework to get some
I have a javascript function that someone made for me. I am kind of
Possible Duplicate: Javascript library: to obfuscate or not to obfuscate - that is the
I'm a noob in Javascript but here is my problem: I'm cleaning up some

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.