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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T02:07:13+00:00 2026-05-11T02:07:13+00:00

I have the following file file: <html> <head> <title></title> <script type=text/javascript src=/Prototype.js></script> <script type=text/javascript>

  • 0

I have the following file file:

<html> <head> <title></title>  <script type='text/javascript' src='/Prototype.js'></script> <script type='text/javascript'> function load_content() {   new Ajax.PeriodicalUpdater('content', '/UpdatedContent/,   {     method: 'post',     frequency: 5   });    //var fileref = document.createElement('link');   //fileref.setAttribute('rel', 'stylesheet');   //fileref.setAttribute('type', 'text/css');   //fileref.setAttribute('href', filename); } </script>  </head>  <body>  <div id='content'></div>  <script type='text/javascript'>     load_content(); </script>  </body> </html> 

Content from UpdatedContent is supposed to be loaded into the ‘content’ div every 5 seconds. What’s weird is that the HTML is loaded but the section at the top of the loaded page is completely stripped out when it gets inserted into ‘content’

The loaded page is essentially this:

<style type='text/css'>   ... lots of css here ... </style>  ... lots of HTML here ... 

There are no , ,

Can CSS not be injected directly into a div?? Is there some reason either the Prototype framework or the browser’s DOM is stripping out the CSS?

How can I include the CSS without making a separate call??

As you can see from the given main file, the page would be completely blank without anything loaded in the ‘content’ div. This is intentional. I am basically wanting to use this as a structure on which to dynamically load updating content on an interval, so that the page doesn’t have to completely reload to do a refresh of the data.

And no, I can’t just hard code the CSS into the above file as the CSS will be changing too.

Edit: Regarding yaauie’s response… now I know why it’s happening, since I’m passing style and content in one single piece. If I separate the CSS into a separate file that can be loaded, how would I then load this via AJAX (preferrably using Prototype) and then, more importantly, set that CSS as the style sheet for the page content?

  • 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. 2026-05-11T02:07:14+00:00Added an answer on May 11, 2026 at 2:07 am

    The <style> tag is only allowed in the <head> of HTML and XHTML, not the <body> or any of its descendants. Web browsers tend to be fairly forgiving of this in the initial parsing of a document, but when changing innerHTML I would expect that the browser would ignore any <style> elements because that type of element is not expected there.

    As a workaround, would it be possible to use inline-CSS in your response, that is use the style='' attribute of the HTML elements you’re passing?

    EDIT: To add the CSS to the <head> would require one of two things:

    • Two round trips to your server:
    • A response that includes both and can be parsed before being inserted

    In this case, I would recommend encoding your two parts into a JSON object before sending. Your callback on the AJAX action should split these and attach them to their appropriate locations (style first to avoid screen jitter)

    {'style':'\ndiv#ajax7373 a {\n  color:#fff;\n  text-decoration:underline;\n  font-weight:bold;\n  \n}\ndiv#ajax7373 {\n  background-color:#ff1cae;\n  color:#ff6ccf;\n}','object':'\n<div id=\'#ajax7373\'>\n\tThere is the contents of your div and a <a href=\'#\'>link<\/a>\n<\/div>\n'} 

    That said, I find it hard to believe that the app favors style/content sepration so strongly and is employing a method where the style must generated by the content. Why not style the whole domain, including the expected return of your AJAX requests? Are the AJAX requested items really going to have enough variance in structure/style to warrant this?

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

Sidebar

Ask A Question

Stats

  • Questions 119k
  • Answers 119k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Yes. Yes. No. It is called the Logarithmic Fourier Transform.… May 11, 2026 at 11:42 pm
  • Editorial Team
    Editorial Team added an answer I would suggest a more powerful hardware. My computer specs… May 11, 2026 at 11:42 pm
  • Editorial Team
    Editorial Team added an answer filter always gives a QuerySet, which is a set of… May 11, 2026 at 11:42 pm

Related Questions

I have the following file: <html> <head> <title></title> <link rel=css type=text/css href=/empty.css title=css />
I failed to find a way to disable the browser detection feature added by
I'm new to XSLT. I'm trying to change the font size of a specific
For simplicity, i have the following file named test.jsp: <script language=javascript> alert(a$b.replace(/\$/g,k)); </script> I

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.