473,386 Members | 1,720 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

onmousedown hangs in Mozilla Help!

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
6 1730


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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Jerry O | last post by:
Hi, I am having trouble implemeting the OnMouseDown event in NN4.7 when used on a Input of type image. It works in Mozilla and N6.2 Is this a limitation or is there a workaround Thanks,
2
by: Bender | last post by:
Hi, I am wanting to capture an onmousedown event without firing the body tags onload event. Also, if anyone could explain why this happens that would be excellent. I can't see how an...
1
by: Weston C | last post by:
I'm trying to use onMouseDown to build a certain behavior into a javascript application (see...
3
by: Jim Lawton | last post by:
Hello, the following bit of (stripped down) code works fine in IE, but on Gecko based browsers - Firefox 1.0.7 Mozilla 1.7.12 it just hangs on the xmlhttpOpen // IE object - works fine...
7
by: teo | last post by:
Hallo, I'd like to debug an .aspx page from the IDE using another browser; I choose Mozilla Firefox (ver 1.8.1: 2006) Mozilla starts but the page never opens and an error occurs; a light...
1
by: kaj28121980 | last post by:
I have a typical senario. My Web component provides action for database backup and restore. while user wants to backup or restore database the user is logged out and redirected to the login page and...
2
by: JRough | last post by:
I cannot log into our web site. I have a test web site and a real site. On Friday I could log in and today Monday I cannot log in. I have 2 databases In PHPMyAdmin, the real database and and a...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.