Click to See Complete Forum and Search --> : load .js file problem


samwangsi
12-22-2003, 09:09 PM
Hello folks, I have some problems with my HP, but the worst is this, I would know how to load a fadeimage script from some .js file and make it work, I will explain this all:

I get the complete script on fadeimage.js:

<script language=javascript>
<!--


function high(which2){
theobject=which2
highlighting=setInterval("highlightit(theobject)",50)
}

function low(which2){
clearInterval(highlighting)
if (which2.style.MozOpacity)
which2.style.MozOpacity=0.3
else if (which2.filters)
which2.filters.alpha.opacity=30
}

function highlightit(cur2){
if (cur2.style.MozOpacity<1)
cur2.style.MozOpacity=parseFloat(cur2.style.MozOpacity)+0.1
else if (cur2.filters&&cur2.filters.alpha.opacity<100)
cur2.filters.alpha.opacity+=10
else if (window.highlighting)
clearInterval(highlighting)
}

//-->
</script>

then on the page, I have to put these two function to work (--->>>):
<a href="page.htm">
<img --->>>onmouseover=high(this)<<<--- style="FILTER: alpha opacity=70); moz-opacity: 0.3" --->>>onmouseout=low(this)<<<--- border="0" src="image.gif" width="56" height="55"></a>

When I put the script directly on the page, this fade effect works perfectly, so I decided to put it into fadeimage.js for maybe make some modification further...

I tried many script to get it loaded, like src and link and document.write(), but nothing, someone please help me to find out how can I load this .js file sucessfully...

I am no expert in these kind of stuff, then make sure to explain every step... :p :p

batfink
12-22-2003, 10:51 PM
Put the functions in the fadeimage.js file.
Within the file you do not need the start script tags
<script language="javascript">
<!--
or the ending script tags

//-->
</script>


Then within the html file that calls the fadeimage.js file put:

<script language="javascript" src="fadeimage.js"></script>

Include all of the above line even the closing script tag and even though there is no code between the tags.
If you put any more javascript code in the html file then you need ANOTHER set of script tags.

Paul Jr
12-22-2003, 11:13 PM
Originally posted by batfink
<script language="javascript" src="fadeimage.js"></script>

To quote fredmv, "You might want to make that a bit more 'complete (http://www.w3.org/TR/REC-html40/interact/scripts.html#h-18.2.1)'. " ;)

fredmv
12-22-2003, 11:21 PM
Originally posted by Paul Jr
To quote fredmv, "You might want to make that a bit more 'complete (http://www.w3.org/TR/REC-html40/interact/scripts.html#h-18.2.1)'. "Interestingly enough, I don't remember saying that! I believe it's Pittimann (http://forums.webdeveloper.com/showthread.php?s=&threadid=23913#post124144) you're referring to. :p

batfink
12-23-2003, 02:44 AM
where can I find a translation forum?:p