Go Back   SitePoint Forums > Program Your Site > JavaScript
User Name
Password
Newsletter Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Build Your Own ASP.NET Website Using C# & VB.NET
Want to learn how to build dynamic ASP.NET Websites from the ground up? Buy SitePoint's book and:

- Find out how to obtain and install the free softawre you'll need
- Learn programming concepts using real-world examples
- Create and customize practical Internet applications while following along with the book
- Learn to code using either C# or VB.NET (or both)
- Get download access to all the code used in the book
ยป Download Your Four Free Sample Chapters Today!

Reply
 
Thread Tools Search this Thread Display Modes
Old Oct 26, 2003, 04:21   #1
Markdidj
♪♪ ♪ ♪ ♪ ♪♪ ♪ ♪♪
 
Markdidj's Avatar
 
Join Date: Sep 2002
Location: Bournemouth, South UK
Posts: 956
Javascript Refresh.

Some people here may know that I've been trying to find a js reloader.
With IE you can change the src of script[0], but with NS you needed an empty script so you can call a new js source to it.....

just done some experimenting and came up with this.......
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>untitled</title> </head> <script type="text/javascript" language="javascript"> 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; } </script> <body> <script type="text/javascript" src="js1.js"></script> <button onclick="changeScript('js2.js')">New JS</button> <button onclick="changeScript('js1.js')">Old JS</button> </body> </html>

give it a try, set up 2 external js files, js1.js and js2.js, with a different alert in each.
works in NS and IE ( don't know about firebird, but not in opera )

Is there something I can add to this script to stop it caching it's js, like a delete???

__________________
Markdidj is offline   Reply With Quote
Old Oct 26, 2003, 05:56   #2
Markdidj
♪♪ ♪ ♪ ♪ ♪♪ ♪ ♪♪
 
Markdidj's Avatar
 
Join Date: Sep 2002
Location: Bournemouth, South UK
Posts: 956
Works absolutely brilliantly with NS and Firebird!!!!!!
Doesn't cache or replaces cache when you call the new JS, it loads the new JS!!! Mad possabilities....

GoodBye IE, Firebird seems like my new browser. I wonder if my sound functions work. . . . . . . . . . . . . .

__________________
Markdidj is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


vBulletin v3.0.3, Copyright ©2000-2004, Jelsoft Enterprises Ltd.