[Webkit-unassigned] [Bug 18042] New: <link> elements to CSS files and <style> elements appended by Javascript don't take effect

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Mon Mar 24 01:38:58 PDT 2008


http://bugs.webkit.org/show_bug.cgi?id=18042

           Summary: <link> elements to CSS files and <style> elements
                    appended by Javascript don't take effect
           Product: WebKit
           Version: 525.x (Safari 3.1)
          Platform: PC
        OS/Version: Windows XP
            Status: UNCONFIRMED
          Severity: Normal
          Priority: P2
         Component: CSS
        AssignedTo: webkit-unassigned at lists.webkit.org
        ReportedBy: yuzhu.shen at gmail.com


If a <link> element pointing to a css file is appended as a child of <body> by
Javascript, it doesn't take effect in WebKit while it does in other browsers
(IE7, FF2/3 are tested). Since WebKit only checks <link> elements in <head> for
style sheets, this css file is ignored. For example, the test.css file is
ignored below.
=========================================
<html>
<head></head>
<body>
   <script type="text/javascript">
     var css_obj=document.createElement('link');
     css_obj.id='test_css';
     css_obj.rel='stylesheet';
     css_obj.type='text/css';
     css_obj.media='screen';
     css_obj.href="test.css";
     document.body.appendChild(css_obj);
   </script>
...

</body>
</html>
=========================================

It should be noted that <link> elements directly specified in <body> will NOT
be ignored in WebKit:
=========================================
<html>
<head></head>
<body>
...
<link id="test_css" rel="stylesheet" type="text/css" media="screen"
href="test.css" />
...
</body>
</html>
=========================================

That is because during the parsing phase, WebKit adds the <link> element as the
child of <head>.

Appending a <sytle> element by Javascript also has the same problem.

This problem affects a very popular Chinese Website:
1. Go to: http://qzone.qq.com
2. On top right, there is a link "怬" (means login). Click on it and a login
dialog should show up.
3. In Safari, the dialog is transparent. While it works fine in IE7, FF2/3.


-- 
Configure bugmail: http://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.



More information about the webkit-unassigned mailing list