Talk:CSS Independent Content

From GreaseSpot Wiki
Jump to navigationJump to search

This might be more suitable in Code snippets?

I agree. --Henrik 05:47, 5 June 2007 (EDT)

sometimes its blank

Hi, I have a problem with this. It could be that I do something wrong. However: about 1 out of 5 times the content stays blank. I tried to change the timeout to 1000. I tested it 20 times, and it worked all the time.

Isn't there a "domIsNowCreatedAndYouCanGoAhead" event that we can listen to instead of using setTimeout?

How about this instead?

It seems it works better

 function $(id) {return document.getElementById(id)};
 var iframe = document.createElement("iframe");
 iframe.setAttribute("id", "settings");
 iframe.setAttribute("style",  "display:block;z-index:1002;position:fixed;overflow:auto;left:30px;top:30px;right:30px;bottom:30px;background-color:white;padding:15px;border:1px solid black");
 iframe.addEventListener('load', showSettings2, false);
 function showSettings2() {    
   $('LIU_settings').contentDocument.body.innerHTML = '<html><body>test</body></html>';

Data URI

Isn't this a prime time to use a data URI?

iframe.src = 'data:text/html;charset=utf-8,'+escape('<html><body>...</body><html>');

Thus avoid all the issues with the DOM rendering and having to wait for load?

I don't think so. Just working with the iframe contents as a string would probably get frustrating. The load event happens pretty quickly since we're just waiting for about:blank to load, with no external resources, and once we're there, we can work with that DOM any way we please. Suppose you could mention it in the article as an option, but I don't really see the point. --Henrik 04:37, 7 June 2007 (EDT)