Click to See Complete Forum and Search --> : Filters with Javascript
stovellp
05-08-2003, 01:51 AM
Greetings. I have the following line of code which seems to be refusing to work for me:
event.srcElement.style.filter = "glow";
Which is strange to me, considering:
event.srcElement.style.color = "#ffcc00";
Works perfectly. All I'm trying to do is make my text glow from a javascript function, but it's this line that seems to be causing me hassles. Any ideas?
~ Paul
I believe you have to use filters[0].apply afterwards. Example:
event.srcElement.style.filter = "glow";
event.srcElement.filters[0].apply;
stovellp
05-08-2003, 02:12 AM
Thanks Jona, I tried that, and had:
event.srcElement.style.filter = "glow";
event.srcElement.filters[0].apply();
(I added the () to it because I'm testing in frontpage and was told it 'did not support this property or method'), yet its still not working. :S Any other ideas?
I just remembered, for some reason, it only works if you add a height attribute:
<html><head>
<script>
function c(){
var z = document.getElementsByTagName("P")[0]
z.style.filter = "glow";
z.style.height = 3;
}
</script>
</head><body>
<p onclick="c()">This is glowing?</p>
</body></html>
stovellp
05-08-2003, 02:42 AM
I copied and pasted exactly what you wrote, but to no success. I can't seem to be able to change style.left either :S which is strange. Oh well, I think I'll give up on it for now, but thanks very much anyway :)
The code that I posted works for me (IE6). Did you make sure you clicked the paragraph? :)
Nevermore
05-08-2003, 12:41 PM
The filter is glow(), with parantheses.
This example works perfectly:
<html><head>
<script>
function c(){
var z = event.srcElement
if(z.style.filter!="glow()"){
z.style.filter = "glow()";} else {
z.style.filter = "shadow()";}
z.style.height = 3;
}
</script>
</head><body>
<h1 onclick="c()">Wow.... Toggle the text! :P</h1>
</body></html>