Uploaded image for project: 'Magnolia'
  1. Magnolia
  2. MAGNOLIA-3110

javascript document.write causing head elements to render in DOM body

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • 4.3
    • 4.2.3
    • admininterface
    • None
    • All browsers, XHTML 1.0 Strict

      In the admin-interface module, inline.js contains 3 document.write statements that create divs for later use by javascript. If we use <cms:links/> in the <head> of the page, this javascript will be included in the head.

      Then, the browser will execute those document.writes during the loading of the <head> element, writing out divs that belong in the <body>. This causes all known browsers to begin the body element immediately in their internal representation. Thus all tags following <cms:links/> will appear in the <body>, according to the DOM.

      This has always been annoyingly messy when using something like firebug to examine a document, but it also caused serious problems when including Scriptaculous, which attempts to find itself in the <head> in order to include more files, which obviously it can't do if it's been moved to the <body>.

      It can be solved with the attached patch, which moves the creation of these divs to the window.onload event (in a crossplatform, unobtrusive fashion).

      The file to be patched is m-m-admininterface/.../admin-js/inline.js

        Acceptance criteria

              gjoseph Magnolia International
              nwing Nickolaus Wing
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved:

                  Bug DoR
                  Task DoD

                    Estimated:
                    Original Estimate - 3h
                    3h
                    Remaining:
                    Remaining Estimate - 3h
                    3h
                    Logged:
                    Time Spent - Not Specified
                    Not Specified