By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,626 Members | 1,653 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,626 IT Pros & Developers. It's quick & easy.

onmousedown hangs in Mozilla Help!

P: n/a
Hi,
I'm trying to make it so when I click a image it prints out the image
again and a load of other stuff. So far i've got this far.

<html>
<head>
<script language="JavaScript" type="">
document.onmousedown = onmousedown;
function onmousedown(e)
{
document.writeln("hello");
}
</script>
</head>
<body bgcolor="FFFFFF">

<img border="1" src="iecadaptor.jpg">

</body>
</html>

but in Mozilla it prints out hello then hangs looking like it's doing
something then I have to press back. In Explorer it works doesn't hang.
Any ideas anyone why it's hanging in mozilla(linux)?
Also if I change the document.writeln("hello"); to

document.writeln("<img border="1" src="iecadaptor.jpg">");

it doesn't print out an image just hangs in mozilla. Any ideas?

Ideally I would like it so document.writeln doesn't have to reload to a
new page and just uses a layer using <div stuff but that's next.

Help anyone please

Thanks

Gary
Jul 20 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a


Gary Mayor wrote:
I'm trying to make it so when I click a image it prints out the image
again and a load of other stuff. So far i've got this far.

<html>
<head>
<script language="JavaScript" type="">
document.onmousedown = onmousedown;
function onmousedown(e)
{
document.writeln("hello");
}
</script>
</head>
<body bgcolor="FFFFFF">

<img border="1" src="iecadaptor.jpg">

</body>
</html>

but in Mozilla it prints out hello then hangs


Well it is hanging there waiting for further document.write calls or a
document.close() call.
--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 20 '05 #2

P: n/a
Martin Honnen wrote:


Gary Mayor wrote:
I'm trying to make it so when I click a image it prints out the image
again and a load of other stuff. So far i've got this far.

<html>
<head>
<script language="JavaScript" type="">
document.onmousedown = onmousedown;
function onmousedown(e)
{
document.writeln("hello");
}
</script>
</head>
<body bgcolor="FFFFFF">

<img border="1" src="iecadaptor.jpg">

</body>
</html>

but in Mozilla it prints out hello then hangs

Well it is hanging there waiting for further document.write calls or a
document.close() call.


Thank you very much the document.close() works a treat. Now I can figure
out the rest.

Cheers
Jul 20 '05 #3

P: n/a
On Tue, 02 Mar 2004 15:39:31 +0000, Gary Mayor <ga**@abertron.co.uk> wrote:
<script language="JavaScript" type="">


Don't do that. The type attribute should be used to specify the scripting
language, not language (it is deprecated).

<script type="text/javascript">

is the correct way to write the tag (with optional src and defer
attributes).

Mike

--
Michael Winter
M.******@blueyonder.co.invalid (replace ".invalid" with ".uk" to reply)
Jul 20 '05 #4

P: n/a
A function cannot be named "onmousedown" or "onMouseDown" or anything
that is already predefined in Javascript (that would rule out "write",
"writeln", "replace", "length", "for", "if", etc..).
document.writeln("<img border="1" src="iecadaptor.jpg">");
The quotations need to be "escaped," that is, it needs to be:
document.writeln("<img border=\"1\" src=\"iecadaptor.jpg\">");

If the quotes were not escaped, then it would be read as "<img
border=" only and then an error would come saying something how the
string wasn't concatenated properly.

Gary Mayor <ga**@abertron.co.uk> wrote in message news:<c2**********@newsg2.svr.pol.co.uk>... Hi,
I'm trying to make it so when I click a image it prints out the image
again and a load of other stuff. So far i've got this far.

<html>
<head>
<script language="JavaScript" type="">
document.onmousedown = onmousedown;
function onmousedown(e)
{
document.writeln("hello");
}
</script>
</head>
<body bgcolor="FFFFFF">

<img border="1" src="iecadaptor.jpg">

</body>
</html>

but in Mozilla it prints out hello then hangs looking like it's doing
something then I have to press back. In Explorer it works doesn't hang.
Any ideas anyone why it's hanging in mozilla(linux)?
Also if I change the document.writeln("hello"); to

document.writeln("<img border="1" src="iecadaptor.jpg">");

it doesn't print out an image just hangs in mozilla. Any ideas?

Ideally I would like it so document.writeln doesn't have to reload to a
new page and just uses a layer using <div stuff but that's next.

Help anyone please

Thanks

Gary

Jul 20 '05 #5

P: n/a
re***@mac.com (Ren Bruns) writes:
A function cannot be named "onmousedown" or "onMouseDown" or anything
that is already predefined in Javascript (that would rule out "write",
"writeln", "replace", "length", "for", "if", etc..).


Sure it can. "for" and "if" are keywords, and cannot be used for
identifiers. The remaining are perfectly good names for functions
(although one should be careful when using them, since they can
conflict with other uses of the identifier).

The following is perfectly legal and works (tested in IE6, Opera 7,
Moz FB, and Netscape 4):

<script type="text/javascript">
function onMouseMove() {
return onmousemove();
}
function onmousemove() {
return writeln();
}
function writeln() {
return write();
}
function write() {
return replace();
}
function replace() {
return length();
}
function length() {
return 42;
}
alert(onMouseMove());
</script>
/L 'please don't top post'
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #6

P: n/a
Ren Bruns wrote:
A function cannot be named "onmousedown" or "onMouseDown" or anything
that is already predefined in Javascript (that would rule out "write",
"writeln", "replace", "length", "for", "if", etc..).
Nonsense. Firstly, "onMouseDown" is not defined in any common DOM.
Secondly, a user-defined function *should* not have one of the mentioned
identifiers (where "for" and "if" make an exception, see below).
Depending on the used DOM, it nevertheless can and would thus overwrite
the intrinsic method. Sometimes this is desired, e.g., when writing
script that blocks popups. Thirdly, no user-defined token, including
method identifiers, may be a reserved word, like "for" and "if".
document.writeln("<img border="1" src="iecadaptor.jpg">");


The quotations need to be "escaped," that is, it needs to be:
document.writeln("<img border=\"1\" src=\"iecadaptor.jpg\">");


No, it needs not to be escaped. Fortunately, ECMAScript
and implementations allow <'> for string delimiter:

document.writeln('<img border="1" src="iecadaptor.jpg">');
[Top post]


Please do not do that, you are wasting precious resources.
PointedEars
Jul 23 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.