scripts can add methods to the prototypes of builtin objects in
JaavScript. I can assign functions to String.prototyp e.*, for
instance. I want to add a method to Node, but when I try to execute
the following IE says "'Node' is undefined." Mozilla works as I
expected it to. Is Node called something else in IE? Does IE not allow
manipulating the prototypes of some builtin objects?
Node.prototype. nt = function() {
return this.nodeType;
}
Ari.
--
Elections only count as free and trials as fair if you can lose money
betting on the outcome. 20 2138
Ari Krupnik wrote:
scripts can add methods to the prototypes of builtin objects in
JaavScript. I can assign functions to String.prototyp e.*, for
instance. I want to add a method to Node, but when I try to execute
the following IE says "'Node' is undefined." Mozilla works as I
expected it to.
Well, actually Mozilla works in - maybe convenient in some
circumstances - but non-expected way.
prototype is property of a JavaScript object; DOM Node is not a
JavaScript object and it has nothing to do with say Object()
constructor (same way as say DIV element has nothing to do with Array
;-)
IE exposes the base [element] interface via behavior mechanics. This
way you can make say each <pelement to have AJAX interface or each
<divacting as media player. But in case of Node I really don't know
what to suggest as it is not an element in (X)HTML / XML sense, it is
unit one level below. Are you trying to uniformly augment every single
element on your page? What is your actual aim? (so maybe some solution
is possible).
Ari Krupnik wrote:
scripts can add methods to the prototypes of builtin objects in
JaavScript. I can assign functions to String.prototyp e.*, for
instance. I want to add a method to Node, but when I try to execute
the following IE says "'Node' is undefined." Mozilla works as I
expected it to. Is Node called something else in IE? Does IE not allow
manipulating the prototypes of some builtin objects?
Node.prototype. nt = function() {
return this.nodeType;
}
There is a base object for the DOM that implements the Node interface,
in Gecko browsers it's called "Node" and you can mess with the
prototype.
IE doesn't have a Node object, though you can extend DOM objects to
some extend using behaviours:
<URL: http://msdn.microsoft.com/library/de...o/creating.asp
>
--
Rob
"Ari Krupnik" <ar*@lib.aerowr ote in message
news:86******** ****@deb.lib.ae ro...
scripts can add methods to the prototypes of builtin objects in
JaavScript. I can assign functions to String.prototyp e.*, for
instance. I want to add a method to Node, but when I try to execute
the following IE says "'Node' is undefined." Mozilla works as I
expected it to. Is Node called something else in IE? Does IE not allow
manipulating the prototypes of some builtin objects?
The Node is not a "built in object", it is a "host object" (or at least,
all objects implementing the Node interface in browser DOMs are host
objects), and host objects are not required to facilitate modification
of their prototypes, expose prototypes (even have prototypes) or expose
constructors.
As a result some hosts may provide those facilities (as Mozilla does)
and others may not (like IE). Both alternatives (and everything in
between) are completely in accordance with the javascript language
specification, and no other specifications (such as the W3C DOM, and its
ECMAScript bindings) has attempted to apply any additional constraints
on host objects in the web browser context.
Richard.
"VK" <sc**********@y ahoo.comwrites:
Ari Krupnik wrote:
>scripts can add methods to the prototypes of builtin objects in JavaScript. I can assign functions to String.prototyp e.*, for instance. I want to add a method to Node, but when I try to execute the following IE says "'Node' is undefined." Mozilla works as I expected it to.
Well, actually Mozilla works in - maybe convenient in some
circumstances - but non-expected way.
I said "the way I expected it to," being fully aware that my
expectation may not be grounded in any reality :=)
Are you trying to uniformly augment every single
element on your page? What is your actual aim? (so maybe some solution
is possible).
I have a bunch of functions that provide XPath-style navigation of the
DOM. Functions like followingSiblin g(node, predicate) that find the
closest sibling in document order for which the function 'predicate'
returns true. Also functions like textValue(node) that concatenates
all character data within a node. Most of these are not specific to
Element, e.g. textValue() of TextNode is its nodeValue. I wanted to
make these functions methods of Node so I could call them as
node.textValue( ) instead of textValue(node) .
It's not that big of a deal. Thanks for explaining the difference
between String and Node to me. I had not internalized the difference
between builtin types and host objects.
Ari.
--
Elections only count as free and trials as fair if you can lose money
betting on the outcome.
Ari Krupnik wrote:
"VK" <sc**********@y ahoo.comwrites:
Ari Krupnik wrote:
scripts can add methods to the prototypes of builtin objects in
JavaScript. I can assign functions to String.prototyp e.*, for
instance. I want to add a method to Node, but when I try to execute
the following IE says "'Node' is undefined." Mozilla works as I
expected it to.
Well, actually Mozilla works in - maybe convenient in some
circumstances - but non-expected way.
I said "the way I expected it to," being fully aware that my
expectation may not be grounded in any reality :=)
Are you trying to uniformly augment every single
element on your page? What is your actual aim? (so maybe some solution
is possible).
I have a bunch of functions that provide XPath-style navigation of the
DOM. Functions like followingSiblin g(node, predicate) that find the
closest sibling in document order for which the function 'predicate'
returns true. Also functions like textValue(node) that concatenates
all character data within a node. Most of these are not specific to
Element, e.g. textValue() of TextNode is its nodeValue. I wanted to
make these functions methods of Node so I could call them as
node.textValue( ) instead of textValue(node) .
No, what you're looking to do isn't possible directly, but you could
write wrappers that would give you the interface you're looking for.
See for instance jQuery, which is basically a wrapper framework; also,
if you want to use XPath you can use XPath directly - though IE doesn't
expose XPath for HTML documents, there's an LGPL implementation: http://js-xpath.sourceforge.net/
which tricks IE into thinking the currently loaded HTML document is an
MSXML-loaded document. And Firefox allows XPath natively with HTML.
(Unfortunately there's no easy solution for Safari and Opera.)
-David
David Golightly wrote:
[...]
No, what you're looking to do isn't possible directly, but you could
write wrappers that would give you the interface you're looking for.
See for instance jQuery, which is basically a wrapper framework; also,
if you want to use XPath you can use XPath directly - though IE doesn't
expose XPath for HTML documents, there's an LGPL implementation:
http://js-xpath.sourceforge.net/
which tricks IE into thinking the currently loaded HTML document is an
MSXML-loaded document. And Firefox allows XPath natively with HTML.
(Unfortunately there's no easy solution for Safari and Opera.)
The WebKit open source project started releasing XPath support in Aug
06[1], it should be picked up by Safari with OS X 10.5.
That puts Safari more-or-less on par with IE in terms of XPath support,
but unfortunately keeps XPath as practically useless on the web for
another couple of years.
It should start to to be viable for intranet or specialist web
applications though.
1. <URL: http://webkit.org/blog/?p=65 >
--
Rob
RobG wrote:
David Golightly wrote:
which tricks IE into thinking the currently loaded HTML document is an
MSXML-loaded document. And Firefox allows XPath natively with HTML.
(Unfortunately there's no easy solution for Safari and Opera.)
The WebKit open source project started releasing XPath support in Aug
06[1], it should be picked up by Safari with OS X 10.5.
That puts Safari more-or-less on par with IE in terms of XPath support,
but unfortunately keeps XPath as practically useless on the web for
another couple of years.
On looking into it a little further, it appears that Opera, much like
IE, has XPath support, but only for XML documents and not HTML. Unlike
IE, fortunately, it's W3DOM compliant. So I bet with a little
determination someone could harness Opera's XPath support for DHTML.
Safari, of course, remains a problem at the present time.
However, for those with huge Ajax apps who don't mind the bandwidth
loss in exchange for the flexibility of XPath, Google's got an
XSLT/XPath implementation entirely in JavaScript which works in all
modern browsers and will if nothing else prove an interesting study: http://code.google.com/p/ajaxslt/
David
"David Golightly" <da******@gmail .comwrites:
Ari Krupnik wrote:
>> I have a bunch of functions that provide XPath-style navigation of the DOM. Functions like followingSiblin g(node, predicate) that find the closest sibling in document order for which the function 'predicate' returns true. Also functions like textValue(node) that concatenates all character data within a node. Most of these are not specific to Element, e.g. textValue() of TextNode is its nodeValue. I wanted to make these functions methods of Node so I could call them as node.textValue () instead of textValue(node) .
if you want to use XPath you can use XPath directly - though IE doesn't
expose XPath for HTML documents, there's an LGPL implementation:
http://js-xpath.sourceforge.net/
which tricks IE into thinking the currently loaded HTML document is an
MSXML-loaded document.
How does it do that? When I need to run an XSLT transformation on an
HTML document in IE, I walk the HTML DOM and construct an X(HT)ML DOM
based on it that IE can transform natively. Are you saying there is a
way to make IE believe that an MSHTML document is an MSXML document
with corresponding methods on its nodes, without copying it over?
Ari.
--
Elections only count as free and trials as fair if you can lose money
betting on the outcome.
"David Golightly" <da******@gmail .comwrites:
On looking into it a little further, it appears that Opera, much like
IE, has XPath support, but only for XML documents and not HTML. Unlike
IE, fortunately, it's W3DOM compliant.
Could you explain the difference, and how being compliant is
unfortunate? I have no experience with client-side XSLT outside of IE
and FF.
However, for those with huge Ajax apps who don't mind the bandwidth
loss in exchange for the flexibility of XPath, Google's got an
XSLT/XPath implementation entirely in JavaScript which works in all
modern browsers and will if nothing else prove an interesting study: http://code.google.com/p/ajaxslt/
I thought the way ajaxslt is implemented in browsers without native
XSLT support was by sending a serialized document to a server,
parsing and transforming it there, then serializing it again, sending
it back and parsing it again on the client. Was I wrong? That sounds a
bit complicated for finding the character data content of a node,
which is the type of processing that I need :=)
Ari.
--
Elections only count as free and trials as fair if you can lose money
betting on the outcome. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Blair Hall |
last post by:
Can anyone please tell me how to correctly use a built in function
when there is a function of the same name in local scope?
Here is an example. Suppose the following is in myApply.py:
def apply(func,seq):
#
# Code can default to
# built-in definition in some cases:
return __builtins__.apply(func,seq)
|
by: Stefan Seefeld |
last post by:
hi there,
I'm trying to convert a tuple to a list,
and get a 'TypeError: list objects are unhashable'.
Can anybody enlighten me as to the possible causes
for this ? Where does hashing come into play during
this conversion ?
Could it be that my runtime is corrupted ?
|
by: BJörn Lindqvist |
last post by:
A problem I have occured recently is that I want to subclass builtin
types. Especially subclassing list is very troublesome to me. But I
can't find the right syntax to use. Take for example this class which
is supposed to be a representation of a genome:
class Genome(list):
def __init__(self):
list.__init__(self)
self =
....
|
by: fb |
last post by:
Does the C language require you to prototype functions? If it's not
required, is it recommended?
|
by: junky_fellow |
last post by:
Can a function have two different prototypes ? If not , then how can
main() have
two different prototypes ?
int main(void)
and
int main argc(int argc, char *argv)
I mean to say, if I declare main in either of the above mentioned ways
my compiler
does not give any warning. How can it accept two different prototypes
?
| |
by: Anders K. Olsen |
last post by:
Hello group
I'm trying to list the users and groups who has read access to a file.
I use .NET 2.0 and FileInfo.GetAccessControl().GetAccessRules(...) and then
loop through the FileSystemAccessRule objects. Using these objects, it is
easy to use rule.IdentityReference.Translate(typeof(NTAccount)) to get the
NTAccount object.
I have noticed that some of the NTAccounts can belong to BUILTIN domains,
|
by: nejucomo |
last post by:
Hi folks,
Quick Synopsis:
A test script demonstrates a memory leak when I use pythonic extensions
of my builtin types, but if I use the builtin types themselves there is
no memory leak.
If you are interested in how builtin/pure-python inheritance interacts
|
by: =?Utf-8?B?UmljaA==?= |
last post by:
Hello,
Does vb2005 have a built-in UnDo feature / object for applications so that I
can undo actions like other windows apps? Or do I have to write my own UnDo
routine?
If vb2005 does have a builtin Undo feature / object / command -- how to
implement it? invoke it?
If there is no builtin undo feature - is there a recommended way to write an
|
by: Steph Barklay |
last post by:
Hi, I'm currently taking a data structures course in C, and my teacher
said that function prototypes are not allowed in any of our code. He
also said that no professional programmers use function prototypes. This
kind of bugged me, because from other people's code that I've seen in
the past, almost all of them use function prototypes. The following also
bugged me. Let's say you have a file called main.c with only the main
function, and...
|
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...
|
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: 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: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |