Custom alerts
by
, 08-04-2014 at 08:30 PM (8191 Views)
It is surprisingly easy to create iframes that go on top of windowed elements (Flash, select boxes etc.):
The onload-part will cause the text to overlay any windowed element if the zindex is high enough (except in Safari). Position: absolute is also possible. Background-color must be specified.Code:<iframe name="ifr" style="position:relative; z-index:10000; background: white" onload="frames['ifr'].document.body.innerHTML='This is an iframe that overlays windowed elements if the zindex is high enough'"></iframe>
So when someone asked me - recently - to create a script producing styleable alert boxes, I immediately thought of using iframes like the one above for this purpose. You can view the result HERE.
EDIT:
I was not happy with the fact that the old script didn't allow us to write html (into the alerts) in the normal way. So I revised it. I also added the possibility to dynamically size the window.
You can find the new script plus demos and explanations HERE.