I saved the code below to an external file which I called colorFader.js, and I'm calling it with:
<script type="text/javascript" src="js/colorFader.js"> </script>
My path (above) is correct, so I'm guessing its something to do with the "onload" command at the end of the code. The code works just fine if I paste it into the <head> tag of my web page adding the standard javascript open and close <script> tags, but as soon as I save it as an external file, it breaks. If anyone could help out as to how to fix this, I would sure appreciate it, as I need to put this on several hundred pages. Thanks
------------------------------------- - //Created by Fader Maker (http://www.bosiljak.hr/fadermaker/)
-
var fmTimer = null;
-
var fmfg = false;
-
function fminit(){
-
if (!document.getElementById) return;
-
fma1=0xff; fma2=0x00; fma3=0xff;
-
fma4=0xff; fma5=0x00; fma6=0x00;
-
if (!fmfg){
-
fmtemp=fma1; fma1=fma4; fma4=fmtemp; fmtemp=fma2; fma2=fma5; fma5=fmtemp; fmtemp=fma3; fma3=fma6; fma6=fmtemp;
-
}
-
fmfg = !fmfg;
-
fmFade();
-
}
-
function fmToHex(n){
-
var hexChars = "0123456789ABCDEF";
-
if (n == 0) return "00";
-
var j, n;
-
var temp = "";
-
while (n != 0){
-
j = n % 16;
-
n = (n - j)/16;
-
temp = hexChars.charAt(j) + temp;
-
}
-
if (temp.length < 2){
-
temp = "0" + temp;
-
}
-
return temp;
-
}
-
-
function fmFade(){
-
obj = document.getElementById('tekst').style;
-
fmcolor = "#" + fmToHex(fma1) + fmToHex(fma2) + fmToHex(fma3);
-
obj.color = fmcolor;
-
if (fma1 != fma4){
-
if (fma4 > fma1){fma1++;}
-
else{fma1--;}}
-
if (fma2 != fma5){
-
if (fma5 > fma2){fma2++;}
-
else{fma2--;}}
-
if (fma3 != fma6){
-
if (fma6 > fma3){fma3++;}
-
else{fma3--;}}
-
if ((fma1 == fma4) && (fma2 == fma5) && (fma3 == fma6)){
-
window.clearTimeout(fmTimer);
-
fminit()}
-
else{
-
fmTimer = window.setTimeout("fmFade()",0);
-
}
-
}
-
onload = fminit
---------------------------------------------------------
The HTML part of the code in the body consists of adding an <span id="tekst" > tag around the text I want to effect. </span>
Also I tried taking off the "onload = fminit" in the external file, but no luck, and I get no error codes either way.
4 2641 Dormilich 8,658
Recognized Expert Moderator Expert
have you already tried window.onload = fminit;?
you should also set breakpoints (at least FF, Safari and (I think) Opera provide debugging tools) to see, if your functions execute.
Yes, I tried that in the body tag of the webpage where I am calling the script, it doesn't seem to make any difference, I haven't tried it in the external file, is that a possibility? thanks for the suggestion. I'm not familiar with setting break points, however it doesn't work in any browser when called as an external .js file.
Dormilich 8,658
Recognized Expert Moderator Expert
I haven't tried it in the external file, is that a possibility?
that’s where you would normally place it.
that’s where you would normally place it.
I tried it, and still no luck.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Weston C |
last post by:
I know of course that you can use <script src=""></script> in an HTML
document to include javascript code you don't want to spill all over the
page.
I'm wondering if there's a way to include other pieces of javascript
code from *within* javascript.... a la #include in C, @import in Java,
use/require in Perl, include()/require() in PHP, etc....
Thanks,
Weston
|
by: joaopedrogoncalves |
last post by:
Hi,
I want to load an external javascript file, get its results and stick
them inside a <div> block. I also
want to do this in several places on a web page.
This way the browser doesn't have to wait for the external resource to
load to show up the page,
thus giving a perceiving faster load time for the user.
|
by: Bob Phillips |
last post by:
Hope someone can help.
I am struggling to write an meta element in JS. The meta element in question
is the refresh element.
This is the code I am using
//--------------------------------------------------------------------------
----
function setMetaContent(metaTag, metaName, value) {
|
by: Matt Kruse |
last post by:
http://www.JavascriptToolbox.com/bestpractices/
I started writing this up as a guide for some people who were looking for
general tips on how to do things the 'right way' with Javascript. Their code
was littered with document.all and eval, for example, and I wanted to create
a practical list of best practices that they could easily put to use.
The above URL is version 1.0 (draft) that resulted. IMO, it is not a
replacement for the FAQ,...
|
by: laredotornado |
last post by:
Hello,
I am tasked with converting an MsAccess db to a MySQL 4 db in a Linux
environment. Can anyone recommend any good freeware/scripts to help me
do this?
Thanks, - Dave
| |
by: James Pemberton |
last post by:
I have recently created a ASP site utilizing Master Pages and all works fine
until I want to proces my javascripts. Just to let you know, most of
cliewnt side scripting is new to me.
But anyway,
I can retrieve and updat ethe value a textbox on the page by using the
document.getElementById('Goals_Main_tbProduct0').value
|
by: Aaron Gray |
last post by:
Hi,
Is there any tool that will concatinate JavaScript files compacting them
spacewise and removing comment fields ?
I have some sed script that sort of does the job but was wondering if there
were any hopefully open source tools that will do the job.
I don't want encryption or obverscation though.
|
by: Neo Geshel |
last post by:
I am experiencing a collision between two scripts, but I cannot find
where it is. I am hoping that someone here can help me.
I have two external JS files that I call into each web page. One
provides me with a standards-compliant way of creating pop-up windows by
simply adding a rel="external" to each anchor. The other allows me to
have toggled definition lists.
When the popupwin.js file is by itself, all anchors with rel="external"...
|
by: donpro |
last post by:
Hi,
I've created a table where the header columns link to an AJAX function
which calls a PHP file and returns content - the purpose is to sort
the table on the heading.
The code snippet is:
<th scope="col"><a href="javascript:;" onclick="loadBookingContent('<?
php echo $SERVERPAGE_URL . SORT_BY_BOOKING; ?>','innerhbl')">Booking</
a></th>
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| | |