>I have an initialization of a div through javascript such as this:
>
>
>window.parent.oDiv.innerHTML="Something"
>
>
>Now, I need to include some HTML in there for a div which contains some relative positioning. That would be an example:
>
>
>window.parent.oDiv.innerHTML="<style>.DivSlideshow {position: relative;}</style><div class=DivSlideshow><div class=DivSlideshowChild>Test</div></div>"
>
>
>Basically, in the initialization of the div, I am passing some styles and some Html. The goal is to have a child element to benefit of absolute positioning as per the parent.
>
>As is, if I only build a page as this:
>
>
><style>
>.DivSlideshow
>{
> position: relative;
>}
>
>.DivSlideshowX
>{
> position: absolute;
> top: 10;
> right: 10;
>}
></style>
>
><div class="DivSlideshow">
>
><div><img src="00000001.jpg" style="width: 1000px; height: 750px;"></div>
>
><div class="DivSlideshowX">X</div>
>
></div>
>
>
>...it would work.
>
>Thus, the X would be included in the parent aligned right.
>
>But, when passing that code through Javascript in innerHtml, the relative declaration does not work.
>
>Are there special considerations in regards to how the relative positioning works when doing such?
I think that the
style element must be a child of
head, so putting it in innerHTML of a
body descendant element won't work.
You can apply inline styling, though, so it would be something like this:
window.parent.oDiv.innerHTML = "<div style='position: relative;'><div style='position: absolute; top: 10; right: 10;'>Test</div></div>";
----------------------------------
António Tavares Lopes