<img src="WebLogo.jpg" title="" alt="Web Logo"
style="width: 130px; height: 185px;"
onmouseover=" dump(this.src);
if (this.src == 'WebLogo.jpg') {
this.src = 'WebLogoNot.jpg';
write();
} else {
this.src = 'WebLogo.jpg';
nowrite();
};"
>
> Hi All- I know no Javascript, but I write on other languages.
> Here is a line I took from other postings. But, dump() does nothing (I
> am using the console window in Firefox),
That is strange, it should yield a runtime error as dump() is not defined,
merely called. Same with nowrite(). Anyway, newline in attribute values
is error-prone and hard to maintain, so move it into a function and call
that function instead.
> and the == never evaluates true, always false.
Are you sure? From the above I rather think it is never evaluated.
> Any ideas - thanks in advance
>
> <img src="WebLogo.jpg" title="" alt="Web Logo"
> style="width: 130px; height: 185px;"
> onmouseover=" dump(this.src);
^^^^
> if (this.src == 'WebLogo.jpg') {
> this.src = 'WebLogoNot.jpg';
> write();
> } else {
> this.src = 'WebLogo.jpg';
> nowrite();
^^^^^^^
> };"
> >
PointedEars
It looks like "dump()" is an internal function. If you replace it with
"dumpit()" then you get an error. I couldn't find any reference to
dump() by fast-googling it though.
To the Original Poster: do you expect dump() to be an internal function
that would give you something ?
Matty
The .src property of an img is an absolute path, not a relative one. You
are testing against a relative path. Placing an alert to alert(this.src)
will show you that. alert(this.src) and it will also show you the full
src to the image. What you want to check is not the image name itself,
but its indexOf in the src.
> this.src = 'WebLogoNot.jpg';
> write();
> } else {
> this.src = 'WebLogo.jpg';
> nowrite();
> };"
> >
<img src="WebLogo.jpg" title="" alt="Web Logo"
style="width: 130px; height: 185px;"
onmouseover="
if (this.src.indexOf('WebLogo.jpg')) {
this.src = 'WebLogoNot.jpg';
} else {
this.src = 'WebLogo.jpg';
};"
onmouseout="this.src = 'sunrise.jpg';"
>
Unless dump(), write() and nowrite() are defined elsewhere, drop them.
If they are defined elsewhere, post them as they may change what happens
in the above.
Ignore Thomas.
--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
A fast test is:
alert( window.dump )
> I couldn't find any reference to
> dump() by fast-googling it though.
Try Googling 'javascript window.dump', the first result is to the
Mozilla DOM reference.
window.dump() is a DOM 0 function that writes to the console.
<URL:http://www.mozilla.org/docs/dom/domref/dom_window_ref18.html#1017188>
--
Rob
Matty.
Gecko implements window.dump(txt) method:
<http://www.mozilla.org/docs/dom/domref/dom_window_ref18.html>
window.dump(text)
Prints messages to the console.
If you have no console available, this method prints nothing but
doesn't raise an error. window.dump is commonly used to print
statements to the console can be used to debug JavaScript used to
access the DOM.
VK says: btw - enjoy the perfect language above :-)
JScript implements global Debug object with write() and writeln()
methods:
<http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/js56jsobjDebug.asp>
Both Gecko one and JScript one are for script testing in some IDE and
meaningless during the runtime execution. I guess though that for a
newcomer from some other language it is rather easy to take them
(especially window.dump) as a local analog of the sysError stream.
The relative path vs. absolute path was not clear in the DOM book I was
looking at. Also, when google'ing, I got an incomplete Javascript 1.5
ref, not a whole, earlier work. I didn't know where else to look.