Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

defineSetter method

Obsolete. Do not use.

Allows developers to create new or override existing Document Object Model (DOM) properties and functions using functionality implemented by a custom Microsoft JScript function. The custom function is used to set the value of a property or a function.

Internet Explorer 8

Syntax


HRESULT retVal = object.defineSetter(propname, pdispHandler);

Parameters

propname [in]

Type: BSTR

Name of the property or function to be modified.

pdispHandler [in]

Type: IDispatch

Name of the JScript function that provides the new functionality.

Return value

Type: HRESULT

If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.

Remarks

The name of the method is preceded and followed by two underscore characters (__).

The IHTMLDOMConstructor::DefineSetter method can be used to override DOM properties, DOM functions, and expandos. You cannot use IHTMLDOMConstructor::DefineSetter to override JScript objects or functions.

When defined for built-in properties or functions, IHTMLDOMConstructor::DefineSetter overrides the built-in property or function. When referring to functions that support arguments, include required arguments in the call to IHTMLDOMConstructor::DefineSetter.

Use the delete operator to delete custom properties or functions created using IHTMLDOMConstructor::DefineSetter and to restore overridden properties or functions to their original functionality.

To cache (save) a function to be overriden with IHTMLDOMConstructor::DefineSetter, assign the function to a variable before overriding it. To invoke behavior cached to a variable, use the apply method or the call method.

The IHTMLDOMConstructor::DefineSetter is only supported in IE8 Standards mode. For more information, see Defining Document Compatibility.

Warning   This feature is not yet standardized and the current implementation is based on similar features in other web browsers. Should the final standard specify an alternate implementation, the current implementation may change.

Examples

This example shows how to create a write only property, a property that cannot be read.


try
{
  document.__defineSetter__("writeOnlyProp", function(value)
  {
    alert("write only: " + value);
  }
} catch(e)
  { alert( "setter not supported: " + e.message); }

// Displays "to-write" in IE8 and "undefined"
// in earlier versions.
document.writeOnlyProp = "to-write";
alert( document.readOnlyProp );

See also

style
rule
currentStyle
attribute
TextNode
attributes
IHTMLDOMConstructorCollection::StaticNodeList
children
defaults
IHTMLDOMConstructorCollection::HTMLGenericElement
styleSheet
IHTMLDOMConstructorCollection::HTMLLinkElement
IHTMLDOMConstructorCollection::HTMLFormElement
IHTMLDOMConstructorCollection::HTMLTextElement
img
XMLHttpRequest
body
font
a
label
ul
ol
li
blockQuote
div
dd
dt
br
dl
hr
p
elements
hn
select
option
input
textArea
button
marquee
html
head
title
meta
base
isIndex
nextID
baseFont
event
screen
window
DocumentCompatibleInfo
documentCompatibleInfoCollection
document
embed
areas
map
area
caption
comment
ins
del
span
table
col
tBody
tFoot
tHead
tr
td
script
noScript
object
param
frame
iframe
fieldSet
legend
frameSet
bgSound
style
XDomainRequest
Storage
Reference
IHTMLDOMConstructor::DefineGetter
IHTMLDOMConstructor::LookupGetter
IHTMLDOMConstructor::LookupSetter

 

 

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.