473,378 Members | 1,469 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,378 software developers and data experts.

Opera javascript problem

The following function is not updating an image in opera 9.02.

upd_on = new Image()
upd_on.src = "images/update_button.gif"
function enableUpdate() {
var update = document.getElementById("cart_Update")
update.disabled = ""
update.style.cursor = "pointer"
update.src = upd_on.src
}

<input type="image" id="cart_Update" src="images/
update_button_disabled.gif" name="cart_Update" value="Update"
disabled="disabled" />

The normally gray image should be replaced with a coloured image. This
works fine in IE and NN, just not in Opera.
The cursor changes, and that's CSS2. Why won't it update the image??

Anyone got any clues before I pull all my hair out?

Feb 15 '07 #1
9 1862
crater wrote:
var update = document.getElementById("cart_Update")
update.disabled = ""
update.disabled = false
--

Martin Honnen
http://JavaScript.FAQTs.com/
Feb 15 '07 #2
On 15 Feb, 15:56, Martin Honnen <mahotr...@yahoo.dewrote:
crater wrote:
var update = document.getElementById("cart_Update")
update.disabled = ""

update.disabled = false

--

Martin Honnen
http://JavaScript.FAQTs.com/
Yes, thanks, Martin.

Picky, though. One would think that "" is equivalent to false as it is
in all other browsers.

Feb 15 '07 #3
On Feb 15, 8:18 am, "crater" <iccar...@gotadsl.co.ukwrote:
On 15 Feb, 15:56, Martin Honnen <mahotr...@yahoo.dewrote:
crater wrote:
var update = document.getElementById("cart_Update")
update.disabled = ""
update.disabled = false
--
Martin Honnen
http://JavaScript.FAQTs.com/

Yes, thanks, Martin.

Picky, though. One would think that "" is equivalent to false as it is
in all other browsers.
Opera actually has it right. In most languages an empty string ("") is
not a null or false value. Since it is a string, if even an empty one,
it is not a boolean false nor is it null. For instance in Ruby an
empty string will always come out as true.

A lot of browser will allow for incorrect values to be assigned and
still parse it just fine. In this case the disabled property is
supposed to take a boolean value, not a string, but using an empty
string apparently works in some browsers.
Feb 16 '07 #4
dd
On Feb 16, 9:41 am, "John Postlethwait" <john.postlethw...@gmail.com>
wrote:
Opera actually has it right. In most languages an empty string ("") is
not a null or false value. Since it is a string, if even an empty one,
it is not a boolean false nor is it null. For instance in Ruby an
empty string will always come out as true.

A lot of browser will allow for incorrect values to be assigned and
still parse it just fine. In this case the disabled property is
supposed to take a boolean value, not a string, but using an empty
string apparently works in some browsers.- Hide quoted text -

- Show quoted text -
Just because "most languages" consider an empty string ("") as true,
and Opera does that too, doesn't make it right. The specification of
JavaScript is what it is, and Opera should respect that if it expects
code written to conform with the language to work properly. JavaScript
has many "truthy" and "falsey" values, and an empty string is
considered falsey. The other browsers aren't just "allowing for
incorrect values", they're following the rules for JavaScript (even if
they're considered bugs, they're bugs that the language developers
have left in for backwards compatibility).

Feb 17 '07 #5
VK
On Feb 15, 7:18 pm, "crater" <iccar...@gotadsl.co.ukwrote:
Picky, though. One would think that "" is equivalent to false as it is
in all other browsers.
Following this logic you should also require the same result from

image.disabled = false;
image.disabled = "";
image.disabled = 0;
image.disabled = undefined;
image.disabled = null;

but I doubt it will work for many browsers, except "little durt" with
"" allowed on FF and IE

Overall empty string is not false and it has nothing to do with it -
no more than with 0. In javascript in _comparison operations_ empty
string is treated as false. It is also treated as false in Boolean
object production: both new Boolean("") and new Boolean(false) will
result in valueOf() == false
In assignments - especially in DOM interface assignments - false, "",
0, null and undefined are values by their own.

Feb 17 '07 #6
On Feb 17, 6:45 am, "dd" <dd4...@gmail.comwrote:
On Feb 16, 9:41 am, "John Postlethwait" <john.postlethw...@gmail.com>
wrote:
Opera actually has it right. In most languages an empty string ("") is
not a null or false value. Since it is a string, if even an empty one,
it is not a boolean false nor is it null. For instance in Ruby an
empty string will always come out as true.
A lot of browser will allow for incorrect values to be assigned and
still parse it just fine. In this case the disabled property is
supposed to take a boolean value, not a string, but using an empty
string apparently works in some browsers.- Hide quoted text -
- Show quoted text -

Just because "most languages" consider an empty string ("") as true,
and Opera does that too, doesn't make it right. The specification of
JavaScript is what it is, and Opera should respect that if it expects
code written to conform with the language to work properly. JavaScript
has many "truthy" and "falsey" values, and an empty string is
considered falsey. The other browsers aren't just "allowing for
incorrect values", they're following the rules for JavaScript (even if
they're considered bugs, they're bugs that the language developers
have left in for backwards compatibility).
You are correct, the specification is what it is and that is exactly
what I said it was.
>From the ECMAScript Specification, page 30:
7.8.4 String Literals
A string literal is zero or more characters enclosed in single or
double quotes.

As you said, just because a browser does it differently doesn't make
it right. A zero character string is still a string, not a boolean.

Mar 6 '07 #7
"John Postlethwait" <jo***************@gmail.comwrote:
<snip>
7.8.4 String Literals
A string literal is zero or more characters enclosed in
single or double quotes.

As you said, just because a browser does it differently
doesn't make it right. A zero character string is still
a string, not a boolean.
It is in the nature of javascript that when a particular type is expected
(in some context) and another type is provided an implicit
type-conversation happens to provide the expected type from the provided
type.

Generally, when a DOM property has a defined type an assignment to that
property also implies a type-conversion from the provided type to the
desired (or an acceptable) type. Thus when assigning to a boolean
property and providing a string that string may be type-converted. And
that type-conversion will likely follow the normal javascript
type-conversion rules.

The type conversion rules for converting a string primitive to a boolean
primitive are that non-empty strings are boolean true and the empty
string is boolean false.

In javascript the 'trueness' of any value is usually judged by the
boolean primitive value that would result from applying the language's
type-conversation to boolean rules to the original value. Thus an empty
string is regarded as a 'false' value, while non-empty strings are true.

Richard.

Mar 6 '07 #8
On Mar 6, 3:30 pm, "Richard Cornford" <Rich...@litotes.demon.co.uk>
wrote:
"John Postlethwait" <john.postlethw...@gmail.comwrote:

<snip>
7.8.4 String Literals
A string literal is zero or more characters enclosed in
single or double quotes.
As you said, just because a browser does it differently
doesn't make it right. A zero character string is still
a string, not a boolean.

It is in the nature of javascript that when a particular type is expected
(in some context) and another type is provided an implicit
type-conversation happens to provide the expected type from the provided
type.

Generally, when a DOM property has a defined type an assignment to that
property also implies a type-conversion from the provided type to the
desired (or an acceptable) type. Thus when assigning to a boolean
property and providing a string that string may be type-converted. And
that type-conversion will likely follow the normal javascript
type-conversion rules.

The type conversion rules for converting a string primitive to a boolean
primitive are that non-empty strings are boolean true and the empty
string is boolean false.

In javascript the 'trueness' of any value is usually judged by the
boolean primitive value that would result from applying the language's
type-conversation to boolean rules to the original value. Thus an empty
string is regarded as a 'false' value, while non-empty strings are true.

Richard.
Fair enough. I was aware that this was the case when using them in an
if statement, but not aware that it was the case for expected types
when assigning values to properties...

Do you happen to know if this is a part of the specification, or if
this is one of those grey areas that the parser developers have to
decide on?

Mar 7 '07 #9
John Postlethwait wrote:
On Mar 6, 3:30 pm, Richard Cornford wrote:
<snip>
>Generally, when a DOM property has a defined type an assignment
to that property also implies a type-conversion from the provided
type to the desired (or an acceptable) type....
<snip>
Fair enough. I was aware that this was the case when using them
in an if statement, but not aware that it was the case for
expected types when assigning values to properties...
It only really applies to assignment to the properties of host objects,
and arguments to host method calls.
Do you happen to know if this is a part of the specification,
or if this is one of those grey areas that the parser developers
have to decide on?
The specifications state what type properties of DOM objects have. That
implies that when you read them they should return the type that the
specification says they should have. In principle it should be possible
for the property to accept and store any type and the type-conversion to
happen at the point of reading the value, but it is probably easier to do
any required type-conversion at the point of assignment.

Richard.

Mar 8 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Spijon | last post by:
Seems opera can not work normally with javascript, does anyone knows how to fix it? Thanks in advance.
6
by: Gustav Medler | last post by:
Hello, there is a known problem with Opera and the execution of content shown in <NOSCRIPT> tag. Everythings works fine, if there is only one simple script like:...
6
by: Shaun Fleming | last post by:
I've been trying to make this simple script compatible across various browsers. It works for IE 6.0 and NS 7 but doesnt work with Opera (I have version 7.11). This is what is supposed to happen:...
13
by: TheKeith | last post by:
Is it just me or does opera and ie not render the float style properly? IE does a sucky job at it, but opera makes a total mess; Mozilla/Firefox renders it correctly however. I'm just trying to be...
6
by: Mark Pappert | last post by:
I've got a linked 'common.js' file that contains one function, on IE and Firefox everything works as expected. However, Opera generates the following error: ...
17
by: windandwaves | last post by:
Hi Folk I recently completed an interactive map. I have now discovered that it is not working in Opera. The address is: http://switch.hosts.net.nz/~admin64/search.php The map is...
6
by: Stefan Mueller | last post by:
After my web page has been loaded I'm doing some tests with a JavaScript. If I figure out that something is wrong I'd like to reload the whole frameset. With Internet Explorer and Mozilla Firefox...
6
by: Jeremy | last post by:
I really want to make my scripts work in Opera. I really, really do. But it seems like an uphill struggle. First of all, I can't get ANY kind of debug output. No error messages in the...
1
by: mwk24 | last post by:
Hi all, I have standard AJAX script that calls a php file to load the latest information and uses xmlHTTP.responseText to write it to innerHTML of a div by id. It works fine on IE/firefox, but I'm...
1
by: mwk24 | last post by:
Hi all, I have standard AJAX script that calls a php file to load the latest information and uses xmlHTTP.responseText to write it to innerHTML of a div by id. It works fine on IE/firefox, but I'm...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: 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
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.