469,344 Members | 5,568 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,344 developers. It's quick & easy.

<SCRIPT> in HTML / Multiple js frameworks

34
Is there any way to dynamically change what script included in the HTML?

Expand|Select|Wrap|Line Numbers
  1. <span id="changeit"><script src="test1.js"></script></span>
  2.  
  3. <input type="button" onClick="document.getElementById('changeit").innerHTML="<script src="test2.js"></script>" />
  4.  
Is there anyway for the <script> include to take affect?

I am doing to get around the fact that i am using two different js frame works.
jQuery and Mootools. There seems to be a conflict.
So, when the user clicks the button I want to unload JQuery and load Mootools.
Jan 23 '08 #1
7 1498
acoder
16,027 Expert Mod 8TB
Give the script tag an id and change its src:
Expand|Select|Wrap|Line Numbers
  1. document.getElementById("scriptID").src="newsrc.js";
Jan 23 '08 #2
gsherp
34
Does the browers load the <script src="..."> file at the beginning when the page loads? Once the <script> file is read by the browers, does it read it again?
Jan 23 '08 #3
mrhoo
428 256MB
javascripts don't disappear when you change or remove the script element that originally loaded them.

You would have to write a routine that deletes every method and property created by that particular script- kind of like removing the first hundred peas that were mixed into a kettle of pea soup.

You have several choices-
find the conflicts and rewrite the libraries, or find a library that does everything you want, or write your own code.
Jan 23 '08 #4
As I recall, the Mootools site is designed such that you can select exactly which function/effects you need and download a .js file that contains only those functions. Have you tried doing that and limiting the functions to exactly what you need on that page (for example, by only selecting the fancy rollover button script or whatever it is you're using)?

In general, any of the big javascript frameworks such as Mootools, Yahoo UI, and Prototype, are meant to be used as THE single framework and are going to be incompatible with one another. I suggest that you determine which framework does the most out of what you want, use that one, and then write the rest of the script you need yourself.
Jan 23 '08 #5
acoder
16,027 Expert Mod 8TB
javascripts don't disappear when you change or remove the script element that originally loaded them.

You would have to write a routine that deletes every method and property created by that particular script- kind of like removing the first hundred peas that were mixed into a kettle of pea soup.

You have several choices-
find the conflicts and rewrite the libraries, or find a library that does everything you want, or write your own code.
Good points and I like the pea soup analogy!
Jan 24 '08 #6
gsherp
34
I found a simple solution avoid the conflicts with using both mootools and jquery
togethor. I just use the jquery no conflict option and in mootools...after some searching on the internet, just don't use '$' when calling a function.
Jan 24 '08 #7
acoder
16,027 Expert Mod 8TB
I found a simple solution avoid the conflicts with using both mootools and jquery
togethor. I just use the jquery no conflict option and in mootools...after some searching on the internet, just don't use '$' when calling a function.
Thanks for posting your solution, but if you hit upon this problem again, you know which advice to follow.
Jan 25 '08 #8

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

2 posts views Thread by Madhav | last post: by
6 posts views Thread by Mike Daniel | last post: by
21 posts views Thread by hemant.singh | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.