WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED CONFIGURATION CHANGED
15648
It is not possible to modify the innerHTML of a HEAD element
https://bugs.webkit.org/show_bug.cgi?id=15648
Summary
It is not possible to modify the innerHTML of a HEAD element
Kevin Decker
Reported
2007-10-23 17:08:45 PDT
Other browsers let you modify the innerHTML of a head element, but WebKit does not. Modifying the innerHTML of head elements is important for a high profile email site.
Attachments
Add attachment
proposed patch, testcase, etc.
David Gatwood
Comment 1
2009-11-28 07:59:39 PST
It's far worse than that. It is not possible to even add elements into the HEAD tag programmatically unless there is already at least one element inside that tag, AFAICT. Steps to reproduce: * Create an iframe element in the HTML. * Populate the iframe by setting iframeelt.contentDocument.body.innerHTML = "...." * Set var elt = iframeelt.contentDocument.getElementsByTagName('head')[0]; * Note that the head element was correctly created implicitly. * Try to add stuff to elt. * Observe the DOM error 7 (NO_MODIFICATION_ALLOWED_ERR). Also tried various other ways of loading the content, including putting a HEAD tag in the BODY, putting the LINK tags in the body where they should have been automatically moved into the HEAD, etc. Nothing worked. This behavior makes it much, much more difficult to write any code that uses iframes and apply CSS styles to the content. Combine that with 31951 and it forced some really ugly workarounds. I eventually gave up and used the src attribute to load a real HTML file that contained a HEAD element with the tags I needed inside it, then blowing out the BODY.
Alexey Proskuryakov
Comment 2
2009-11-30 17:05:11 PST
> It's far worse than that. It is not possible to even add elements into the > HEAD tag programmatically unless there is already at least one element inside > that tag, AFAICT.
I made a test case from this description, but it works fine. I was able to successfully insert a LINK element inside an empty auto-created HEAD. In any case, let's not discuss this here. Difficulties with manipulating HEAD content via DOM Core APIs would likely have a different cause than innerHTML, and this bug is about the latter. Please file a new bug if you have a test case that works in Firefox, but not in Safari.
Anne van Kesteren
Comment 3
2023-08-23 07:35:17 PDT
Works fine these days:
http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C!DOCTYPE%20html%3E%0A%3Cscript%3E%0Adocument.head.innerHTML%20%3D%20%22%3Clink%3E%22%0A%3C%2Fscript%3E
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug