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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T22:30:02+00:00 2026-06-11T22:30:02+00:00

There is a dynamically created <style> tag and I’m concatenating an additional piece of

  • 0

There is a dynamically created <style> tag and I’m concatenating an additional piece of css to it. This is part of a larger framework for dynamically loading modules.

Originally it created new style tags but due to the famous “31 stylesheet limit” this is no longer an option, so I decided to recycle existing style tags (unless they contain too many rules or if the new string contains @import, in which case a new one has to be created regardless).

Anyway, I got it working in all major browsers (FF2+, Chrome14+, Opera10+, IE7+, Safari 4.0+) and now IE6 is giving me headaches.

I am familiar with this error from other scenarios, but I’ve never seen in this this context. Also, don’t bother any IE6-timeywimey, I’m well aware of it. But this is unfortunately an exceptional case where IE6 support is still required.

Screenshot of the bug and part of the source code

Note that the bracket count is solely for estimating and debugging purposes. The try/catch wasn’t around the cssText += originally, I added it because I found it throwing an exception in IE6.

  • 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-11T22:30:04+00:00Added an answer on June 11, 2026 at 10:30 pm

    I found the answer to my own question. It turns out IE6 has an obscure security measure that disallows manipulation of elements indirectly created by other scripts (even if they come from the exact same origin/domain).

    In this case the simplified method was working fine, but the actual code was failing. The only difference was that the actual code was using jQuery to store data, create elements and insert elements. That last action (inserting elements) was the problem.

    I changed

            /**
             * @param {jQuery|HTMLElement} $nextnode
             */
            function addStyleTag( text, $nextnode ) {
                var s = document.createElement( 'style' );
                // IE: Insert into document before setting cssText
                if ( $nextnode ) {
                    // If a raw element, create a jQuery object, otherwise use directly
                    if ( $nextnode.nodeType ) {
                        $nextnode = $( $nextnode );
                    }
                    $nextnode.before( s );
                    /* ... */
    

    to:

            /**
             * @param {jQuery|HTMLElement} nextnode
             */
            function addStyleTag( text, nextnode ) {
                var s = document.createElement( 'style' );
                // IE: Insert into document before setting cssText
                if ( nextnode ) {
                    // If a jQuery object, get raw element, otherwise use directly
                    if ( nextnode.jquery ) {
                        nextnode = nextnode.get( 0 );
                    }
                    nextnode.parentNode.insertBefore( s, nextnode );
                    /* ... */
    

    And that fixed the problem.

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

Sidebar

Related Questions

I have a dynamically created table which in the last <td> there is a
Is there a way to style text font dynamically base on selected font in
I'm aware of dynamic script/css loading by adding <style> or <link> tags to head
I have a CSS stylesheet that's dynamically created on the server, and returned via
I have some code dynamically created by Sigma, which looks like this: <div id=myGrid1_headDiv
Is there a way to dynamically create a selectItem list? I dont really want
Is there a way to dynamically create a kind of sub-domain that goes between
I have a bunch of dynamically created *.BAT files. These BAT files are used
I want to add three labels into a cell dynamically, cell is created dynamically
I have a form with multiple textboxes which are created dynamically, now all these

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.