473,770 Members | 1,953 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.g if"
function enableUpdate() {
var update = document.getEle mentById("cart_ Update")
update.disabled = ""
update.style.cu rsor = "pointer"
update.src = upd_on.src
}

<input type="image" id="cart_Update " src="images/
update_button_d isabled.gif" name="cart_Upda te" value="Update"
disabled="disab led" />

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 1886
crater wrote:
var update = document.getEle mentById("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...@yaho o.dewrote:
crater wrote:
var update = document.getEle mentById("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...@gotad sl.co.ukwrote:
On 15 Feb, 15:56, Martin Honnen <mahotr...@yaho o.dewrote:
crater wrote:
var update = document.getEle mentById("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...@gotad sl.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.c omwrote:
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.comwr ote:
<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...@litote s.demon.co.uk>
wrote:
"John Postlethwait" <john.postlethw ...@gmail.comwr ote:

<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
2354
by: Spijon | last post by:
Seems opera can not work normally with javascript, does anyone knows how to fix it? Thanks in advance.
6
4775
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: http://www.dr-wald.de/test/Opera-NOSCRIPT.html Switching off Javascript will show the alternative content. Javascript enabled will only show the JS-content, _not_ the <NOSCRIPT> content.
6
2726
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: when the user clicks a button in the main window, a dialog window pops up. In the dialog the user enters a university to search for. When the string is submitted, the dialog then shows all the matches found in the database. The user picks one and...
13
2541
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 a good boy following the html 4.01 strict spec, and taking it a step further by not using tables for layout, but it's becoming a real pain. You would figure putting a strict doctype declaration at the top of the page would create a uniformity in...
6
1955
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: http://www.mdocs.ca/scripts/common.js Unknown context Syntax error while loading (line 61) -^
17
1668
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 basically 20+ images over each other, each of which are transparent gifs.
6
6671
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 I can reload the whole frameset with parent.location.href = "index.html"; However, this doesn't work with Opera. Does someone know how to do that with Opera?
6
2727
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 "javascript console" - but then, I have never seen ANYTHING in Opera's javascript console. Is there some kind of voodoo I need to perform in order to make that work? Then, when Opera doesn't like something about a script (even if it works fine in...
1
1597
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 having trouble with Opera Mobile, due to javascript caching (at least that is my suspicion) I installed Opera for Windows and had the same problem (described below), until I set the Other Modification setting to 0 in opera.ini (i.e. to set Opera to...
1
2755
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 having trouble with Opera Mobile, due to javascript caching (at least that is my suspicion) I installed Opera for Windows and had the same problem (described below), until I set the Other Modification setting to 0 in opera.ini (i.e. to set Opera to...
0
9617
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10254
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10036
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9904
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8929
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7451
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6710
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
3607
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2849
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.