You are not really taking advantage of jQuery.. and document.write()
calls that are not present on page load will always clear the page.
You can simply do:

$(document).ready(function(){

    //$('#jt').after('<script type="text/javascript" src="write.js"></
script>'); //insert the script, but this would clear the page too

    $('#jt').after('<p>I am here</p>'); // writes 'I am here' right
after <div id="dt">

});

read the docs at docs.jquery.com, should make things clearer. hope
this helps.

- ricardo

On Oct 18, 3:09 pm, jt <[EMAIL PROTECTED]> wrote:
> I'd like to load a js file into a specific location but it replaces
> the page with what is being written out. I suspect there's a fairly
> obvious answer (maybe it can't be done). Here's a basic version of the
> code and I would like it to write 'here i am' in the dom after <div
> id='jt'></div>. Currently, it replaces the dom. Also if I take it out
> jquery and place it at the end, it still replaces the page:
>
> <html>
>   <head>
>   <script type='text/javascript' src='/jsource/jquery.min.js'></
> script>
>   <script type='text/javascript'>
>   $(document).ready(function(){
>       alert("I am ready");
>       var pom=document.createElement('script');
>       var jt=document.getElementById('jt');
>       pom.setAttribute('type','text/javascript');
>       pom.setAttribute('src','write.js');
>       jt.appendChild(pom);
>
>   });
>   </script>
>   </head>
> <body>
>
> <b>Before things started</b> to make senese:
> <div id='jt'></div>
>
> here are other things here
> </body>
>
> write.js:
> document.write('here i am');

Reply via email to