Difference between revisions of "Talk:CSS Independent Content"

From GreaseSpot Wiki
Jump to navigationJump to search
(Data URI)
Line 22: Line 22:
     $('LIU_settings').contentDocument.body.innerHTML = '<html><body>test</body></html>';
     $('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?

Revision as of 17:53, 6 June 2007

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?