[This was submitted as a bug to Opera; I'm posting it here, after not
seeing mention of this in a newsgroup search]:
In HTML 4.01, a <button> element can take 1 of 3 types:
type=submit (default)
type=reset
type=button
The Javascript to create a button element dynamically is
elem = document.create Element('button ');
elem.type = 'reset';
Running this code in Opera 7.54 gives the message:
"DOMExcepti on: NO_MODIFICATION _ALLOWED_ERR"
My intuition is that the official Opera.com response will be that this
is as required by the DOM spec, which lists "type" as a readonly property.
And I'll give you that, but how can the spec be correct? It refers to the
HTML 4.01 spec, which lists the 3 possible values for type; but the DOM
interface shows no other method for altering the value of type.
In other words, how do I use Javascript to create the equivalent of either
<button name="rset" type="reset">Re set Button</button>
or
<button name="push" type="button">P ush Button</button>
??
For what it's worth, Mozilla makes the "type" property read/write; and
IE requires its own bizarre argument to createElement (as:
elem = document.create Element('<butto n type="reset" value="Reset">R eset</button>')
hj 7 2210
On 08/06/2005 00:47, Howard Jess wrote: [This was submitted as a bug to Opera;
It isn't a bug. Just some oddness in the DOM specification.
[snip]
In HTML 4.01, a <button> element can take 1 of 3 types:
Unfortunately, the BUTTON element is all but useless due to IE's woeful
inability to use it properly. You'd be better off using the INPUT
element, which has a modifiable type property.
[snip]
My intuition is that the official Opera.com response will be that this is as required by the DOM spec, which lists "type" as a readonly property. And I'll give you that, but how can the spec be correct?
You should ask that on the W3C mailing lists.
Notice that in DOM 2 HTML, the INPUT element's type attribute was
modified from read-only to read/write, but the BUTTON element was not.
Either it was overlooked, or there was a reason.
[snip]
Mike
--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail. [This was submitted as a bug to Opera; It isn't a bug. Just some oddness in the DOM specification.
Right; the "oddness" makes dynamicly created button elements a lot
less useful, though; and in Mozilla this "oddness" is ignored (type
is read/write), and in Safari, although the property isn't directly
modifiable, setAttribute('t ype',...) has the expected effect.
[snip]
In HTML 4.01, a <button> element can take 1 of 3 types: Unfortunately, the BUTTON element is all but useless due to IE's woeful inability to use it properly. You'd be better off using the INPUT element, which has a modifiable type property.
Yes and no. If you see you're running in IE (by detecting its "woeful"
behavior, of course), there are measures you can take.
You should ask that on the W3C mailing lists.
OK, good advice.
Notice that in DOM 2 HTML, the INPUT element's type attribute was modified from read-only to read/write, but the BUTTON element was not. Either it was overlooked, or there was a reason.
Bummer. Does nobody use this stuff?
hj
Howard Jess wrote: [This was submitted as a bug to Opera;
It isn't a bug. Just some oddness in the DOM specification.
Right; the "oddness" makes dynamicly created button elements a lot less useful, though; and in Mozilla this "oddness" is ignored (type is read/write),
At least for <input> elements I remember that originally Mozilla
followed the readonly for the type property specified in DOM Level 1
until someone file a bug complaining that that disallows dynamically
creating the different input types. It is likely that for <button>
elements the approach was similar.
So the problem is indeed with the DOM spec but of course browsers should
follow common sense and allow dynamical creation of the different types
of input and button elements, after all the DOM should allow you to
programmaticall y create anything that static HTML allows.
--
Martin Honnen http://JavaScript.FAQTs.com/
On Wed, 08 Jun 2005 01:47:38 +0200, Howard Jess
<howard..@dhite chnologies.dot. com> wrote: [This was submitted as a bug to Opera; I'm posting it here, after not seeing mention of this in a newsgroup search]:
The Javascript to create a button element dynamically is
elem = document.create Element('button '); elem.type = 'reset'; Running this code in Opera 7.54 gives the message:
"DOMExcepti on: NO_MODIFICATION _ALLOWED_ERR"
Good catch, thanks: the specification probably should be corrected to
allow you to set type. I have confirmed your bug report. As you mentioned
we're probably "correct" spec-wise but when the specs are inconsistent..
--
Hallvord R. M. Steen
Opera Software http://www.opera.com/
Howard Jess wrote: The Javascript to create a button element dynamically is elem = document.create Element('button '); elem.type = 'reset';
.... <button name="rset" type="reset">Re set Button</button>
For what it's worth, Mozilla makes the "type" property read/write; and IE requires its own bizarre argument to createElement (as:
elem = document.create Element('<butto n type="reset" value="Reset">R eset</button>')
Interesting post. I didn't try this, but what about cloning an
existing button element (of the type you desire), and then modifying
the remaining elements?
Also, I use button, when possible (ie. browser dependent), because that
way I can indicate the access key by underlining it. e.g. <button ...
accessKey=o><u> O</u>K</button>. I seem to recall that you have to be
careful about how that text changes in some browsers. Possibly it is
necessary to nest the text in a div? I forget, but just beware if you
are doing things like
Mor<u>e</u> >> changing to/from
L<u>e</u>ss <<
Csaba Gabor from Vienna
Csaba Gabor wrote: Howard Jess wrote: The Javascript to create a button element dynamically is elem = document.create Element('button '); elem.type = 'reset'; ... <button name="rset" type="reset">Re set Button</button>
For what it's worth, Mozilla makes the "type" property read/write; and IE requires its own bizarre argument to createElement (as:
elem = document.create Element('<butto n type="reset" value="Reset">R eset</button>')
Interesting post. I didn't try this, but what about cloning an existing button element (of the type you desire), and then modifying the remaining elements?
I'm not sure how you would do this; what do you mean by "an existing
button element"? What if I'm creating the entire page using Javascript?
In any case, I do have a (not very clean) workaround: a combo function that
asks for element type (and name, which has a similar problem in IE) all
at one time; this lets me code it as (for brevity here, no error checking):
function createButton(ty pe,name) {
var div = document.create Element('div');
div.innerHTML=' <button type="'+type+'" name="'+name+'" ></button>';
return div.firstChild;
}
I'd rather not use the non-standard innerHTML, but it's pretty well-
supported by all DOM-ish browsers, so ...
hj
Howard Jess wrote: Csaba Gabor wrote: Howard Jess wrote: For what it's worth, Mozilla makes the "type" property read/write; and IE requires its own bizarre argument to createElement (as:
elem = document.create Element('<butto n type="reset" value="Reset">R eset</button>')
Interesting post. I didn't try this, but what about cloning an existing button element (of the type you desire), and then modifying the remaining elements?
[...] What if I'm creating the entire page using Javascript?
Then you would have far more serious problems than this.
PointedEars
--
When you have eliminated all which is impossible, then
whatever remains, however improbable, must be the truth.
-- Sherlock Holmes This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: ojvm |
last post by:
ok. thanks again for the time spend reading this.
this code adds 2 controls in html form but it places in top of the
form.
i want this
control1 control2
control1 control2
control1 control2
|
by: frogman042 |
last post by:
My daughter is playing around trying to learn JavaScript and she wrote
a small program that prints out a message in increasing and decreasing
font size and color changes. She is using document write and it works
fine until she puts it into a function and then calls the function from
a button with onClick. This also seems to work OK, with the exception
that the page is cleared, and the curser changes (and stays) as an
hourglass.
In...
|
by: Hazzard |
last post by:
I just realized that the code I inherited is using all asp.net server
controls (ie. webform controls) and when I try to update textboxes on the
client side, I lose the new value of the textbox when submitting the form to
update the database. The server doesn't have the client side value any more.
It seems to me that as I begin to write the client side javacript code for
form validation and client side editing capabilities in order to save...
|
by: Lloyd Sheen |
last post by:
This IDE is driving me nuts. I needed another button so I copied an
existing one, changed the Text and the id and position by drag and drop.
Well then I run and get the following:
Control 'Button19' of type 'Button' must be placed inside a form tag with
runat=server
Can the IDE not do what it is supposed to do. It seems that it is a fight
to make it do anything or did I do something wrong? It would seem silly to
have to create a...
|
by: Nathan |
last post by:
I have an aspx page with a data grid, some textboxes, and an update button.
This page also has one html input element with type=file (not inside the data
grid and runat=server).
The update button will verify the information that has been entered and
updates the data base if the data is correct. Update will throw an exception
if the data is not validate based on some given rules. I also have a custom
error handling page to show the...
| |
by: Sathyaish |
last post by:
I am no JavaScript progammer, and unfortunately am having to babysit an
old code base that has a lot of JavaScript in it.
I have two questions:
(1) Can two HTML controls have the same name? It looks like the obvious
answer is NO.
(2) What if? What if the developer has given two HTML controls the same
name, i.e has created the same button more than once with exactly the
|
by: Iddo |
last post by:
Hi,
I am having a strange problem...
I have an HTML file which has 2 script tags:
1) <script language="javascript" id="ABC" src="ABC.js" />
2) <script id="general" language="javascript">
function foo()
{
alert("aaa");
}
</script>
|
by: Atli |
last post by:
Introduction
At some point, all web developers will need to collect data from their users. In a dynamic web page, everything revolves around the users input, so knowing how to ask for and collect this data is essential to any developer.
This article is a basic tutorial on how to user HTML Forms, the most common method of data collection.
Assumptions
- Basic HTML knowledge.
- Basic PHP knowledge.
HTML Forms
A common and simple way of...
|
by: dwmartin18 |
last post by:
Hello everyone. I have quite the puzzling problem with a script I have been working on lately. I have created a function that can be called to create a new html element (e.g. input, select, div, etc.). It is used as follows:
addElementToPage("writeroot", "input", "type:button, text:testText, value:testvalue, onclick:test1")
The first argument is an ID of the location where the new element it to be appended. The second argument is the type...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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,...
|
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...
|
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();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
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...
| |