Options Livescript ReloadLivescript reload is off
Login
5th
< >

Changing a script element using the DOM

This method I discovered in 2003 and is now commonly used throughout the internet. It is a very powerful little piece of javascript, especially when combined with server side programming such as asp or php.

The orginal code:

function changeScript(newScript) {
oldScript=document.getElementsByTagName("script" )[1]
var newEl = document.createElement('script');
newEl.setAttribute('type', 'text/javascript');
newEl.setAttribute('src', newScript);
oldScript.parentNode.replaceChild(newEl,oldScript);
changeScript.el = newEl;
return true;
}

Security Warning! Beware!

If you embed a third party javascript element within your website you are allowing that website full javascript access. Using the method shown here they can, for example, send both yours and your user's login information back to their site!

Contacting Livescript

32 Shaftesbury Road,
Charminster,
Bournemouth,
Dorset,
BH8 8ST

Tel:

(+44) 1202 250527

Mob:

(+44) 7780 570838


Or use the contact form
Page took 172ms to execute. Last modified 26 weeks ago