Ajax Talk - Asynchronous javascript and xml discussion board
 FAQ   Search    Usergroups      Register   Profile   Check your messages   Log in 
Signup now to enjoy a range of free membership advantages !!
Ajax Talk - Moderators Wanted
Problem with dynamically loaded script

 
Post new topic   Reply to topic    Ajaxtalk.com Forum Index -> AJAX Programmers Exchange
View previous topic :: View next topic  
Author Message
Snyke
Forum Assistant
Forum Assistant


Joined: 20 Jun 2006
Posts: 87
Location: Zurich

PostPosted: Sun Jul 09, 2006 1:24 am    Post subject: Problem with dynamically loaded script Reply with quote

Ok this is my problem:
I want to load prototype dynamically from within one of my scripts
using the following code:

---JS---
// Load Prototype
var head = document.getElementsByTagName("head")[0];
loadPrototype: {
GM_log("Loading prototype");
script = document.createElement('script');
script.id = 'prototypeScript';
script.type = 'text/javascript';
script.src = "http://prototype.conio.net/dist/prototype-1.4.0.js";
head.appendChild(script);
};
---/JS---

And then call the functions in it from the same script again, like
this:

---JS---
unsafeWindow.onload = function init(){
// Use prototype:
element = $('someId');
};
---/JS---

But it doesn't work, and I only get an error that the function is not
defined.
While using FireBug I can easily call it and everything works just
fine...

I'm using this in a GreaseMonkey script so there is absolutely no way I
can possibly add it statically...
_________________
[::[ Snyke.net ]::]
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
deejay
Forum Assistant
Forum Assistant


Joined: 17 May 2006
Posts: 78
Location: Netherlands

PostPosted: Mon Jul 10, 2006 8:47 am    Post subject: script.defer='defer' Reply with quote

Hi,

Maybe like this ?

loadPrototype()
{
var script=document.createElement('SCRIPT');
var head=document.getElementsByTagName('HEAD')[0];
script.language='javascript';
script.src='http://prototype.conio.net/dist/prototype-1.4.0.js';
script.defer='defer';
head.appendChild(script);
}
_________________
please correct me if i am wrong
seo-expertglobalwarming
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Ajaxtalk.com Forum Index -> AJAX Programmers Exchange All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
 Advertisements
 XML & Copyright Notice 
    


Powered by phpBB © 2001, 2005 phpBB Group

What is according to Wikipedia: Ajax Web2.0 XML E4X


Link to our site:

  


del.icio.us digg spurl wists simpy newsvine blinklist furl blogmarks yahoo! myweb smarking ma.gnolia segnalo reddit fark technorati cosmos


Normal Bookmark


Partner Button Links:
Codecrunch.com: Webmaster Tutorials    One Ajax


Partner Text Links:
quomon | web20log | ajaxmatters | tableless | 456bereastreet | music charts | gift ideas | competitions | free xbox 360 | link trade ?


Credits:
it consultancy & project management lead generation zoekmachine optimalisatie steal these buttons seo expert