|
|
(3 intermediate revisions by 2 users not shown) |
Line 7: |
Line 7: |
| With allows you to do a series of operations on an object without having to name the object each time. | | With allows you to do a series of operations on an object without having to name the object each time. |
|
| |
|
| == Example (Basic) == | | == Example == |
|
| |
|
| <pre> | | <tabber> |
| Rem With sample
| | JavaScript= |
| 'With statement allows accessing properties on a specified object
| | <syntaxhighlight lang="JavaScript"> |
| | |
| Dim theURL, theTitle
| |
| With document
| |
| theURL = .URL
| |
| .title = "New Title"
| |
| theTitle = .title
| |
| document.write(.URL & "<br>")
| |
| document.write(.title & "<br>")
| |
| End With
| |
| | |
| </pre>
| |
| | |
| == Example (JavaScript) ==
| |
| | |
| <pre>
| |
| // With sample
| |
| /* With statement allows accessing properties on a specified object */ | | /* With statement allows accessing properties on a specified object */ |
|
| |
|
| var theURL, theTitle; | | var theURL, theTitle; |
| with (document) { | | with (document) { |
| theURL = URL;
| | theURL = URL; |
| title = "New Title";
| | title = "New Title"; |
| theTitle = title;
| | theTitle = title; |
| document.write(URL + "<br>"); | | NSB.Print(URL); |
| document.write(title + "<br>"); | | NSB.Print(title); |
| } | | } |
|
| |
|
Line 42: |
Line 26: |
|
| |
|
| (function($){ | | (function($){ |
| theURL = $.URL;
| | theURL = $.URL; |
| $.title = "New Title";
| | $.title = "New Title"; |
| theTitle = $.title;
| | theTitle = $.title; |
| document.write($.URL + "<br>");
| | NSB.Print($.URL); |
| document.write($.title + "<br>");
| | NSB.Print($.title); |
| }(document)
| | }(document) |
| ); | | );</syntaxhighlight> |
| </pre> | | |-| |
| | BASIC= |
| | <syntaxhighlight lang="vb.net"> |
| | Rem With sample |
| | 'With statement allows accessing properties on a specified object |
| | |
| | Dim theURL, theTitle |
| | With document |
| | theURL = .URL |
| | .title = "New Title" |
| | theTitle = .title |
| | Print .URL |
| | Print .title |
| | End With</syntaxhighlight> |
| | </tabber> |
|
| |
|
| == Output == | | == Output == |
Latest revision as of 23:40, 24 July 2019
With object
- [statements]
End With
Description
With allows you to do a series of operations on an object without having to name the object each time.
Example
/* With statement allows accessing properties on a specified object */
var theURL, theTitle;
with (document) {
theURL = URL;
title = "New Title";
theTitle = title;
NSB.Print(URL);
NSB.Print(title);
}
/* a better way to perform With */
(function($){
theURL = $.URL;
$.title = "New Title";
theTitle = $.title;
NSB.Print($.URL);
NSB.Print($.title);
}(document)
);
Rem With sample
'With statement allows accessing properties on a specified object
Dim theURL, theTitle
With document
theURL = .URL
.title = "New Title"
theTitle = .title
Print .URL
Print .title
End With
Output
File:///C:Browse.htm
New Title