Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Very Simple, bug?

2 views
Skip to first unread message

one man army

unread,
Nov 20, 2005, 12:02:19 AM11/20/05
to
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), and the == never evaluates
true, always false. 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();
};"
>

Thomas 'PointedEars' Lahn

unread,
Nov 20, 2005, 12:17:27 AM11/20/05
to
one man army wrote:

> 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

matty

unread,
Nov 20, 2005, 12:48:38 AM11/20/05
to

Thomas 'PointedEars' Lahn wrote:
> That is strange, it should yield a runtime error as dump() is not defined,

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

Randy Webb

unread,
Nov 20, 2005, 1:13:15 AM11/20/05
to
one man army said the following on 11/20/2005 12:02 AM:

> 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), and the == never evaluates
> true, always false. 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') {

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/

RobG

unread,
Nov 20, 2005, 2:32:34 AM11/20/05
to
matty wrote:
> Thomas 'PointedEars' Lahn wrote:
>
>>That is strange, it should yield a runtime error as dump() is not defined,
>
>
> It looks like "dump()" is an internal function. If you replace it with
> "dumpit()" then you get an error.

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

unread,
Nov 20, 2005, 3:02:36 AM11/20/05
to

RobG wrote:
> 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>
>
Thanks. I guess Google is not *that* good I typed "javascript dump" and
didn't see anything obvious (i was looking for a heading saying "the
dump function")

Matty.

VK

unread,
Nov 20, 2005, 6:11:45 AM11/20/05
to

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.

one man army

unread,
Nov 20, 2005, 11:34:41 AM11/20/05
to
thanks all, especially Randy.

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.

0 new messages