views:

62

answers:

2

I want the html are fully loaded then execute the inline javascript because this script stops the load of the html document.

To try to solve this problem I put the inline javascript code at the end inside a div then i use the jquery .append method

$("#subhimedia").appendTo("#himedia");

This works and appends the inline js that is located inside #subhimedia and takes it inside the #himedia div.

The probblem is that duplicate the #subhimedia div and in internet explorer it freeze the browser.

The inline javascript is:

<!--JavaScript Tag // Tag for network 258: Hi-Media Portugal // Website: Lifecooler // Page: HOME // Placement: HOME_MREC_300x250 (1653713) // created at: Aug 29, 2008 1:35:27 PM-->
                <script language="javascript"><!--
                document.write('<scr'+'ipt language="javascript1.1" src="http://adserver.adtech.de/addyn|3.0|258|1653713|0|170|ADTECH;loc=100;target=_blank;grp=[group];misc='+new Date().getTime()+'"></scri'+'pt>');
    //-->
                </script><noscript><a href="http://adserver.adtech.de/adlink|3.0|258|1653713|0|170|ADTECH;loc=300;grp=[group]" target="_blank"><img src="http://adserver.adtech.de/adserv|3.0|258|1653713|0|170|ADTECH;loc=300;grp=[group]" border="0" width="300" height="250"></a></noscript>

    <!-- End of JavaScript Tag -->

You could see the url here: http://www.niceoutput.com/jquery/

Thanks in advance for your help

Mário

+1  A: 

Since you are using jQuery, wouldn't

  $(document).ready(function(){
    //your code to execute when HTML is fully loaded
  });

work?

Vincent Ramdhanie
Wouldn't `jQuery(function () { })` be even better, conciseness-wise? :)
deceze
it didn't work, or maybe i'm doing something wrong.If i put the inline javascript inside the $(document).ready how can i reference it to the div#himedia beacause i want the inline javascript to load it inside that div.thanks for help
niceoutput
You can reference any element of the dom using jQuery selectors. For example $("div#himedia").html("YOUR HTML STRING");
Vincent Ramdhanie
Don't work, it's supposed to load the inline javascript not the html
niceoutput
Can you explain the use case for loading inline javascript this way? Can the same not be accomplished by calling a function when you are done loading the page?
Vincent Ramdhanie
What i want is to load the html first then load the div#himedia with the inline javascript, and i don't know how to do it.I hope you understand it.Thanks in advance
niceoutput
+1  A: 

use

$(document).ready(function(){

 // your code here

});

before writing any jquery codes..

joberror
didn't work....
niceoutput