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

IE error using setTimeout and Select Tag in a frame.

P: n/a
Hi,

I've got a funny and wanted to know if there is a fix out there for
this.

I display a jsp inside a frame that monitors the database and reloads
itself via the setTimeout js function. To improve functionality I
added a dropdown where the user can select the frequency of reloading.

The bug is this: Let the page reload by itself. Then click on the
dropdown and do not select a value, just leave it open until the page
reloads itself. You should get a blank page. Any ideas?

** test.jsp
<%
try {
String MILLIS = request.getParameter("mills");

int millis = 15000;

if (MILLIS != null && MILLIS.equals("") == false) {
millis = Integer.parseInt(MILLIS) * 1000;
} else {
MILLIS = "15";
}

System.out.println("here...");
System.out.println("millis = " + millis);
%>

<html>
<head>
<title>Test</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="expires" CONTENT="0">
<script>
function reload()
{
setTimeout('document.mon.submit();', <%=millis%>);
}
reload();
</script>
</head>
<body>
<%=new java.util.Date()%>
<form name="mon" class="form" >
Update this page every
<select name="mills" onchange="javascript:document.mon.submit();">
<option value="7" <% if ("7".equals(MILLIS)) { %>selected<% }
%>>7 seconds</option>
<option value="15" <% if ("15".equals(MILLIS)) { %>selected<% }
%>>15 seconds</option>
<option value="30" <% if ("30".equals(MILLIS)) { %>selected<% }
%>>30 seconds</option>
</select>
</form>
</body>
</html>
<%
System.out.println("here too...");

} catch (Exception e) {
System.out.println("e.getMessage() = " + e.getMessage());
e.printStackTrace();
}
%>
** end

Thanks,
Martin
Jul 20 '05 #1
Share this Question
Share on Google+
8 Replies


P: n/a
Martin wrote:
The bug is this: Let the page reload by itself. Then click on the
dropdown and do not select a value, just leave it open until the page
reloads itself. You should get a blank page. Any ideas?
Don't post server-side script code, post what the client gets (see
`view-source:$URI', Edit, View Source e.g.) instead. When you look
at the generated code, you will most certainly find the error for
yourself. Try `javascript:' in the Location Bar and enable the
display of script errors in Internet Options, too.
onchange="javascript:document.mon.submit();">


`javascript:' URIs don't belong into event handlers. Within JavaScript
code, `javascript:' is merely a label. If supported, it is ignored (since
no statement refers to it.) If not supported, it results in a script error.
(If the UA uses the label as an identifier for the script language to be
used, it is b0rken since the default scripting language is defined with
the `meta' element in the `head'.)

And reference the form with the recommended (by
W3C-DOM 2 HTML) document.forms['mon'] instead.
PointedEars
Jul 20 '05 #2

P: n/a
Thomas 'PointedEars' Lahn <Po*********@web.de> writes:

[about onevent="javascript:..."]
(If the UA uses the label as an identifier for the script language to be
used, it is b0rken since the default scripting language is defined with
the `meta' element in the `head'.)


However, there is no way to have a script in a language different from
the default scripting language. That is probably why IE uses the label
to specify the language (as pretty much the only widely used browser that
supports more than one scripting langauge): You can have javascript
and vbscript on the same page that way.

I don't like it either, but given that there is no better alternative,
I can understand why they do it.

/L
--
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 #3

P: n/a
Lasse Reichstein Nielsen wrote:
Thomas 'PointedEars' Lahn <Po*********@web.de> writes:
[about onevent="javascript:..."]
(If the UA uses the label as an identifier for the script language to be
used, it is b0rken since the default scripting language is defined with
the `meta' element in the `head'.)
However, there is no way to have a script in a language different from
the default scripting language.


You're wrong. I have posted (IE-)working examples with VBScript and
J(ava)Script here IIRC more than one time. Google is your friend. [psf 6.1]
That is probably why IE uses the label to specify the language (as pretty
much the only widely used browser that supports more than one scripting
langauge): You can have javascript and vbscript on the same page that way.
You can have that without a proprietary interpretation of labels.
I don't like it either, but given that there is no better alternative,
I can understand why they do it.


All scripts in a page share the same namespace, there is no need to define
what language is meant unless there is a subroutine with the same identifier
in languages different from the default scripting language. And if that, one
can encapsulate that ambiguous statement in user-defined subroutines with
different identifiers within `script' elements whose language is properly
enough defined by the `language' and/or the `type' attribute.
PointedEars
Jul 20 '05 #4

P: n/a
On Thu, 30 Oct 2003 21:10:40 +0100, Thomas 'PointedEars' Lahn
<Po*********@web.de> wrote:
Lasse Reichstein Nielsen wrote:
However, there is no way to have a script in a language different from
the default scripting language.
You're wrong. I have posted (IE-)working examples with VBScript and
J(ava)Script here IIRC more than one time. Google is your friend. [psf 6.1]


Could you post a simple snippet which has different script languages
used in intrinsic events without using the script label syntax?
All scripts in a page share the same namespace, there is no need to define
what language is meant unless there is a subroutine with the same identifier
in languages different from the default scripting language.


I really don't understand this you're suggesting:

onload="if (1==2) alert('a')"

doesn't need to be told it's javascript because all scripts on the
page share the same namespace?

Jim.
--
comp.lang.javascript FAQ - http://jibbering.com/faq/

Jul 20 '05 #5

P: n/a
Thomas 'PointedEars' Lahn <Po*********@web.de> writes:
You're wrong. I have posted (IE-)working examples with VBScript and
J(ava)Script here IIRC more than one time. Google is your friend. [psf 6.1]
You are probably referring to <news:3F**************@PointedEars.de>.

It is correct that you can circumvent the problem by using only one
language in the event handler attributes and using the other language
in global functions that can be called cross-language.

However, that still doesn't allow you to have JScript in one event
attribute and VBScript in another. IE's label interpretation does.

(Google did let me find "psf 6.1". Luckily, I can't seem to get it to
store the cookie with my configuration. Otherwise I wouldn't have found
a page in German :).
All scripts in a page share the same namespace, there is no need to define
what language is meant unless there is a subroutine with the same identifier
in languages different from the default scripting language. And if that, one
can encapsulate that ambiguous statement in user-defined subroutines with
different identifiers within `script' elements whose language is properly
enough defined by the `language' and/or the `type' attribute.


That avoids the problem, but it doesn't solve it.

/L
--
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
Jim Ley wrote:
Thomas 'PointedEars' Lahn wrote:
Lasse Reichstein Nielsen wrote:
However, there is no way to have a script in a language different
from the default scripting language.


You're wrong. I have posted (IE-)working examples with VBScript and
J(ava)Script here IIRC more than one time. Google is your friend.
[psf 6.1]


Could you post a simple snippet which has different script languages
used in intrinsic events without using the script label syntax?


As I wrote, I did it before:

http://groups.google.com/groups?q=vb...num=1&filter=0

The `foobar()' JavaScript call can be as well placed in an
event handler, provided that the default scripting language
is JavaScript because it is the only scripting language the
UA has a script engine for, or (better) because it is defined
as the default scripting language (see below.)
All scripts in a page share the same namespace, there is no need to
define what language is meant unless there is a subroutine with the
same identifier in languages different from the default scripting
language.


I really don't understand this you're suggesting:

onload="if (1==2) alert('a')"

doesn't need to be told it's javascript because all scripts on the
page share the same namespace?


No, it is considered to be JavaScript because of

<meta http-equiv="Content-Script-Type" content="text/javascript">

within the `head' element as recommended by the HTML 4.01 Specification.

The problem that can occur is that foobar() may be subroutine
intrinsic to more than one supported scripting language, say
FooScript and BarScript. Then you need to call that routine
from a function of which the scripting language is known:

<head>
...
<meta http-equiv="Content-Script-Type" content="text/javascript">
<script type="text/fooscript">
func foo
foobar{}
cnuf
</script>

<script type="text/barscript">
(bar)
[
foobar();
]
</script>
...
</head>
<body>
...
<... onwhatever="foo(); bar();" ...>
...
</body>
PointedEars
--
"Use any version of Microsoft Frontpage to create your site. (This won't
prevent people from viewing your source, but no one will want to steal it.)"
Tipp gegen Quellcode-Klau
<http://www.vortex-webdesign.com/help/hidesource.htm>
Jul 20 '05 #7

P: n/a
On Fri, 31 Oct 2003 03:21:49 +0100, Thomas 'PointedEars' Lahn
<Po*********@web.de> wrote:
Jim Ley wrote:
You're wrong. I have posted (IE-)working examples with VBScript and
J(ava)Script here IIRC more than one time. Google is your friend.
[psf 6.1]
Could you post a simple snippet which has different script languages
used in intrinsic events without using the script label syntax?


As I wrote, I did it before:


Please lookup the usage of "intrinsic events" it's from the HTML
recommendation. Your example does not use different script languages
in intrinsic events.
onload="if (1==2) alert('a')"

doesn't need to be told it's javascript because all scripts on the
page share the same namespace?


No


So you are agreeing now with Lasse's original assertion, going back on
your "you're wrong"

|> However, there is no way to have a script in a language different from
|> the default scripting language.
|
|You're wrong.
The problem that can occur is that foobar() may be subroutine
intrinsic to more than one supported scripting language, say
FooScript and BarScript.
I didn't mention any function other than alert, that is not a problem
(although your claim that all languages on a page share the same
namespace is not actually sustainable, it's true to Windows IE, but
there is no requirement that it be true.
<... onwhatever="foo(); bar();" ...>


This relies on javascript (or whatever but a single language) Can you
please provide an example which backs up your previous assertion that
using the HTML 4 techniques does not limit you to one script language
in your intrinsic events.

The IE method of overriding the JScript label (perfectly legal to do
so in ECMAScript btw.) seems like an elegant solution.

Jim.
--
comp.lang.javascript FAQ - http://jibbering.com/faq/

Jul 20 '05 #8

P: n/a
Jim Ley wrote:
Thomas 'PointedEars' Lahn wrote:
Jim Ley wrote:
You're wrong. I have posted (IE-)working examples with VBScript
and J(ava)Script here IIRC more than one time. Google is your
friend. [psf 6.1]

Could you post a simple snippet which has different script
languages used in intrinsic events without using the script label
syntax?
As I wrote, I did it before:


Please lookup the usage of "intrinsic events" it's from the HTML
recommendation.


There's no need, I know what I'm writing about.
Your example does not use different script languages in intrinsic
events.
I used subroutines from different script languages as I read you wanted
to see.
onload="if (1==2) alert('a')"

doesn't need to be told it's javascript because all scripts on
the page share the same namespace?


No


So you are agreeing now with Lasse's original assertion, going back
on your "you're wrong"


You misunderstood what I wrote.
|> However, there is no way to have a script in a language
|> different from the default scripting language.
|
| You're wrong.
Which is correct. We were talking about
scripts, not (intrinsic) event handlers.
<... onwhatever="foo(); bar();" ...>


This relies on javascript (or whatever but a single language)


Yes, of course. I did not dispute that.
The IE method of overriding the JScript label (perfectly legal to do
so in ECMAScript btw.)
According to ECMAScript Editions 1 and 3, section 12.12 (Ed. 2 does not
mention labels):

| A Statement may be prefixed by a label. Labelled statements are only
| used in conjunction with labelled break and continue statements.
seems like an elegant solution.


It *seems*, yes.
PointedEars
Jul 20 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.