Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #30292
| From | Stefan Weiss <krewecherl@gmail.com> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Re: A few problems with looping thru a set of elements with the same"name" specifier. |
| Date | 2016-04-18 19:46 +0200 |
| Organization | albasani.net |
| Message-ID | <nf36i5$an2$1@news.albasani.net> (permalink) |
| References | <571371bd$0$5928$e4fe514c@news.xs4all.nl> <nf035v$b42$1@news.albasani.net> <5713bf9d$0$5947$e4fe514c@news.xs4all.nl> |
R.Wieser wrote:
>> Use getElementsByName() or querySelector() / querySelectorAll().
>
> I take it thats the answer to questions #1 and #2, including the related one
> (?).
>
> Too bad, the function will get a bit more complex because of it (I take it
> your answer equals an "cannot be done", not "don't know if its possible")
I never use shortcuts like `document.{name}`, myself, when there are methods
that explicitly select what I want. I just checked in Chromium and Firefox,
and neither of them just add elements to `document` by their `name`
attributes... maybe I misunderstood what you were talking about.
Either way, the method calls aren't that complex. They are also explicit in
what they do, and allow you to avoid naming conflicts with other properties
of `document` (and apparently, browser compatibility issues). They also
always return a collection of elements or a single element, depending on
which method is used, but independent of how many matches exist in the document.
>> Unfortunately, we don't know what browser that is.
>
> Thats on purpose. The script should run on as many browsers as possible.
> I would not want you to waste time to find a solution for a specific
> browser, only to than being told it doesn't work for yet another one.
Then that's a relevant requirement in itself. If you really want to support
as many browsers as possible, that limits the range of possible solutions.
The query selector methods, for example, do not exist natively on all
browsers. IMHO, you will probably have to define a cut-off point somewhere,
or you'll find yourself supporting horribly outdated and broken engines for
little actual benefit.
>> Why would a popup blocker prevent execution?
>
> Sorry, you're asking the wrong person. Its just that I saw that name as
> the caption of the popup box that told me it stopped a popup from appearing
> (quite a bit of irony there :-) )
>
>> Does your function open a new window?
>
> Yes. At one point in time I had an "alert" box in the function to show me
> the contents of the "document.foo.length" property (thats how I discovered
> it would not work for a single element).
>
> Though when I removed it the script still got, at some other computer and
> browser, blocked at some point.
Dialogs (alert, confirm, prompt) usually don't trigger popup blockers, and
certainly not after they've been removed from the code :)
It's impossible to say what's going on here without looking at the code.
- stefan
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
A few problems with looping thru a set of elements with the same "name" specifier. "R.Wieser" <address@not.available> - 2016-04-17 13:22 +0200
Re: A few problems with looping thru a set of elements with the same "name" specifier. Stefan Weiss <krewecherl@gmail.com> - 2016-04-17 15:30 +0200
Re: A few problems with looping thru a set of elements with the same"name" specifier. "R.Wieser" <address@not.available> - 2016-04-17 18:54 +0200
Re: A few problems with looping thru a set of elements with the same"name" specifier. Stefan Weiss <krewecherl@gmail.com> - 2016-04-18 19:46 +0200
Re: A few problems with looping thru a set of elements with thesame"name" specifier. "R.Wieser" <address@not.available> - 2016-04-18 20:28 +0200
Re: A few problems with looping thru a set of elements with thesame"name" specifier. Stefan Weiss <krewecherl@gmail.com> - 2016-04-18 22:54 +0200
Re: A few problems with looping thru a set of elements withthesame"name" specifier. "R.Wieser" <address@not.available> - 2016-04-19 11:24 +0200
Re: A few problems with looping thru a set of elements withthesame"name" specifier. Stefan Weiss <krewecherl@gmail.com> - 2016-04-19 15:42 +0200
Re: A few problems with looping thru a set of elements withthesame"name" specifier. Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-04-19 20:08 +0200
Re: A few problems with looping thru a set of elements with the same "name" specifier. Stefan Weiss <krewecherl@gmail.com> - 2016-04-17 15:36 +0200
csiph-web