473,405 Members | 2,167 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

how to call random .js

4
Expand|Select|Wrap|Line Numbers
  1. <html> 
  2. <head> 
  3. <title> 
  4. Random Script 
  5. </title>
  6.  
  7.  
  8. <script type="text/javascript"> 
  9. var srcs=new Array("ie.js","iesi.js")//Script sources 
  10. var randomScript 
  11. if(randomScript=document.createElement('script')) 
  12. randomScript.type="text/Javascript" 
  13. randomScript.src=srcs[(Math.floor(Math.random()*srcs.length))]; 
  14. document.getElementsByTagName('head')[0].appendChild(randomScript); 
  15. </script> 
  16. </head> 
  17. <body> 
  18. hello 
  19. </body> 
  20. </html>
  21.  

this is not working. so please tell me how i call random js files
Jan 16 '07 #1
1 1428
AricC
1,892 Expert 1GB
Expand|Select|Wrap|Line Numbers
  1. <html> 
  2. <head> 
  3. <title> 
  4. Random Script 
  5. </title>
  6.  
  7.  
  8. <script type="text/javascript"> 
  9. var srcs=new Array("ie.js","iesi.js")//Script sources 
  10. var randomScript 
  11. if(randomScript=document.createElement('script')) 
  12. randomScript.type="text/Javascript" 
  13. randomScript.src=srcs[(Math.floor(Math.random()*srcs.length))]; 
  14. document.getElementsByTagName('head')[0].appendChild(randomScript); 
  15. </script> 
  16. </head> 
  17. <body> 
  18. hello 
  19. </body> 
  20. </html>
  21.  

this is not working. so please tell me how i call random js files
I didn't test your code out but I think your problem starts here:
var randomScript
if(randomScript=document.createElement('script'))

How can the variable randomScript = document.createElement? The value of randomScript is undefined.
Jan 16 '07 #2

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

Similar topics

19
by: Riko Wichmann | last post by:
hi everyone, I'm googeling since some time, but can't find an answer - maybe because the answer is 'No!'. Can I call a function in python inline, so that the python byte compiler does...
6
by: RTB | last post by:
I've been trying to replace my old PHP/iframe random quotes script with a PHP/javascript without success. http://www.just-quotes.com/wow/random.php <script...
4
by: Matthew Wilson | last post by:
I want to write a function that each time it gets called, it returns a random choice of 1 to 5 words from a list of words. I can write this easily using for loops and random.choice(wordlist) and...
0
by: floppyzedolfin | last post by:
Hello. I'm working in Visual Studio, language is C#, and I am coding a cryptography program. At some point, I need random values, and rather than using a made- for- it random generator, I use...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.