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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T10:51:28+00:00 2026-06-09T10:51:28+00:00

I’m building a code that injects a div into a site. The problem is

  • 0

I’m building a code that injects a div into a site. The problem is that I can’t assign the css values via javascript, as they don’t seem to take place on the document (not all of them).

Here is the code:

var barRoot = document.createElement('DIV'); 
barRoot.style.backgroundColor='#44AA44';
barRoot.style['height']='30px';
barRoot.style['width']='100%';
barRoot.style['position']='absolute';
barRoot.style['font-size']='14px';
barRoot.style['font-family']='Arial, Helvetica, sans-serif';
barRoot.style['z-index']='99999001';
barRoot.style['font-weight']='bold';
barRoot.style['top']='0pt';
barRoot.style['left']='0pt';
barRoot.style['color']='White';
barRoot.style['padding']='0pt';
barRoot.style['margin']='0pt';
barRoot.style['border']='0px solid rgb(0, 0, 0)';
barRoot.id =  'irobRootElem1';  
document.body.insertBefore(barRoot, document.body.firstChild);  

var heartImg = document.createElement('IMG');   
heartImg.src = 'heart.png';  
heartImg.style['float']='left';  
heartImg.style['margin-left']='8px';  
heartImg.style['margin-top']='5px';  
heartImg.style['margin-right']='8px';  
barRoot.appendChild(heartImg);  
  • 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-09T10:51:29+00:00Added an answer on June 9, 2026 at 10:51 am

    If you want to assign styles via JavaScript, the property names are not exactly the same as in your CSS file.

    Check this list in the w3c doc

    But as suggested, use of classes are a lot more easier to use than programmatically set styles.

    Here is the list extracted from the w3 link above :

    Document Object Model (DOM) Level 2 Style Specification

    Version 1.0

    W3C Recommendation 13 November, 2000

    azimuth
    background
    backgroundAttachment
    backgroundColor
    backgroundImage
    backgroundPosition
    backgroundRepeat
    border
    borderCollapse
    borderColor
    borderSpacing
    borderStyle
    borderTop
    borderRight
    borderBottom
    borderLeft
    borderTopColor
    borderRightColor
    borderBottomColor
    borderLeftColor
    borderTopStyle
    borderRightStyle
    borderBottomStyle
    borderLeftStyle
    borderTopWidth
    borderRightWidth
    borderBottomWidth
    borderLeftWidth
    borderWidth
    bottom
    captionSide
    clear
    clip
    color
    content
    counterIncrement
    counterReset
    cue
    cueAfter
    cueBefore
    cursor
    direction
    display
    elevation
    emptyCells
    cssFloat
    font
    fontFamily
    fontSize
    fontSizeAdjust
    fontStretch
    fontStyle
    fontVariant
    fontWeight
    height
    left
    letterSpacing
    lineHeight
    listStyle
    listStyleImage
    listStylePosition
    listStyleType
    margin
    marginTop
    marginRight
    marginBottom
    marginLeft
    markerOffset
    marks
    maxHeight
    maxWidth
    minHeight
    minWidth
    orphans
    outline
    outlineColor
    outlineStyle
    outlineWidth
    overflow
    padding
    paddingTop
    paddingRight
    paddingBottom
    paddingLeft
    page
    pageBreakAfter
    pageBreakBefore
    pageBreakInside
    pause
    pauseAfter
    pauseBefore
    pitch
    pitchRange
    playDuring
    position
    quotes
    richness
    right
    size
    speak
    speakHeader
    speakNumeral
    speakPunctuation
    speechRate
    stress
    tableLayout
    textAlign
    textDecoration
    textIndent
    textShadow
    textTransform
    top
    unicodeBidi
    verticalAlign
    visibility
    voiceFamily
    volume
    whiteSpace
    widows
    width
    wordSpacing
    zIndex
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a French site that I want to parse, but am running into
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I am currently running into a problem where an element is coming back from
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I used javascript for loading a picture on my website depending on which small
I have a jquery bug and I've been looking for hours now, I can't
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function

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.