0

IE tells me there's an error on line 17, which is the onload method of the body tag. So here's the code...

<script language="javascript" type="application/javascript">
		function startUp() {
			setFocus();
		}
		function setFocus(){
			document.frmSearch.txtSearch.focus();
			document.frmSearch.txtSearch.select();
		}
	</script>

And here's how it's called:

<body onload="startUp();">

I tested this in Safari, Firefox, IE 8, Opera, and Chrome. Works in all except IE 8.

3
Contributors
6
Replies
8
Views
7 Years
Discussion Span
Last Post by loligator
0

Rather than using <body onload="startUp();"> try this in a global area of your javascript.

window.onload = startUp;

0

Rather than using <body onload="startUp();"> try this in a global area of your javascript.

window.onload = startUp;

thanks for the suggestion. I tried it but it still doesn't work. I'm no longer receiving an script error, but nothing happens. it does still work in firefox though.

0

Instead of using form name and form element name try using getElementById

If it doesn't works for you, i am expecting that onloading of the body the script is calling...so while that js function is executiing , the form was not loaded at that time.

0

okay, to try and resolve the issue i've altered the code and made it even simpler...

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <link rel=stylesheet href="css/main.css" type="text/css" media="screen" />
    <title>Web site</title>
    <script language="javascript" type="application/javascript">
		function startUp(){
			alert("Test");
		}
	</script>
</head>
<body onload="startUp();">

This again works in FF but IE produces this error:

Webpage error details

User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.2; MS-RTC EA 2; OfficeLiveConnector.1.4; OfficeLivePatch.1.3)
Timestamp: Wed, 17 Mar 2010 19:02:26 UTC


Message: Object expected
Line: 16
Char: 1
Code: 0
URI: http://server/index.php

What object is IE expecting that no other browser seems to care about?

0

I forgot to mention, line 16 is the <body onload="startUp();"> line.

0

I found the problem! The line <script language="javascript" type="application/javascript"> should be <script language="javascript"[B] type="text/javascript"[/B]> imagine that...

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.