Yep, you'll have to add the javascript nodes in the HTML you're inserting into the DIV manually.

WTF, i'll be a nice guy and post my routines for it. you'll have to adapt them yourself ;)

   function parseJavascript (htmlElement) {
       var scripts = $('SCRIPT', htmlElement);
      var htmlHead = $('HEAD')[0];
       for (var i=0; i<scripts.length; i++) {
           var script = scripts[i];
if (script.src) {
               var scriptsInHead = $('SCRIPT', htmlHead);
               var found = false;
               for (var j=0; j<scriptsInHead.length && (!found); j++) {
                   if (scriptsInHead[j].src == script.src) found = j;
               }
               var e = document.createElement("script");
               e.type="text/javascript";
               e.language='JavaScript';
               e.src = script.src;
               if (found===false) {
console.log ("mb.desktop.parseJavascript: appending "+e.src+" to HEAD.");
                   htmlHead.appendChild(e);
               } else {
console.log ("mb.desktop.parseJavascript: removing then re-adding "+e.src+" to HEAD."); scriptsInHead[found].parentNode.removeChild (scriptsInHead[found]);
                   htmlHead.appendChild (e);
} } else {
               var s = scripts[i].innerHTML;
               s = s.replace (/<!--/, '');
               s = s.replace (/-->/, '');
               s = s.replace (/\s\s/g, '');
            //console.log (s);
               eval(s);
           }
       }




Steve wrote:
Hi, I'm a jQuery newbie. Basically, I'm trying to load an html file
into a div when a button is clicked. The html file contains
external .js and .css files for the Greybox widget. I can't get
Greybox working, do I have to do something special to load the js and
css before the load method? Appreciate any help.

--------------- test.html ---------------------

 $(document).ready(function(){
   $("#btn").click(function(){

     $("#demo").load("greybox.html");
   });
 });

--------------- greybox.html ---------------------

<script type="text/javascript">
    var GB_ROOT_DIR = "greybox/";
</script>

<script type="text/javascript" src="greybox/AJS.js"></script>
<script type="text/javascript" src="greybox/gb_scripts.js"></script>
<link href="greybox/gb_styles.css" rel="stylesheet" type="text/css" />

<a href="http://google.com/"; title="Google" rel="gb_page_fs[]">Launch
google.com in fullscreen window</a>


Reply via email to