473,651 Members | 2,551 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

explain what this means

Hi Folk

I found the following function somewhere on the web. I am not sure how it
works, but I am sure that it is very useful:

function getObj(name) {
if (document.getEl ementById){
if(document.get ElementById(nam e)) {
if(document.get ElementById(nam e).style) {
this.obj document.getEle mentById(name);
this.style document.getEle mentById(name);
}
}
}
else if (document.all){
this.obj = document.all[name];
this.style = document.all[name].style;
}
else if (document.layer s) {
this.obj = document.layers[name];
this.style = document.layers[name];
}
}

I guess that it finds out how the browser refers to elements with a specific
IDs and then returns them. However, I dont really understand "this." other
than that it refers to the function itself and how it or what it returns.
can someone explain it?

TIA

- Nicolaas
Aug 24 '05 #1
5 1656
Code is not valid.
You didn't copy/paste right

Hi Folk

I found the following function somewhere on the web. I am not sure how it
works, but I am sure that it is very useful:

function getObj(name) {
if (document.getEl ementById){
if(document.get ElementById(nam e)) {
if(document.get ElementById(nam e).style) {
this.obj document.getEle mentById(name);
this.style document.getEle mentById(name);
}
}
}
else if (document.all){
this.obj = document.all[name];
this.style = document.all[name].style;
}
else if (document.layer s) {
this.obj = document.layers[name];
this.style = document.layers[name];
}
}

I guess that it finds out how the browser refers to elements with a specific IDs and then returns them. However, I dont really understand "this." other than that it refers to the function itself and how it or what it returns.
can someone explain it?

TIA

- Nicolaas

Aug 24 '05 #2
It looks like it wants to be a javascript class
with a member obj set to the node named by name
and a member style pointing of course to the
style associate with obj

Problem is that this code will not work as is.
windandwaves wrote:
Hi Folk

I found the following function somewhere on the web. I am not sure how it
works, but I am sure that it is very useful:

function getObj(name) {
if (document.getEl ementById){
if(document.get ElementById(nam e)) {
if(document.get ElementById(nam e).style) {
this.obj document.getEle mentById(name);
this.style document.getEle mentById(name);
}
}
}
else if (document.all){
this.obj = document.all[name];
this.style = document.all[name].style;
}
else if (document.layer s) {
this.obj = document.layers[name];
this.style = document.layers[name];
}
}

I guess that it finds out how the browser refers to elements with a specific
IDs and then returns them. However, I dont really understand "this." other
than that it refers to the function itself and how it or what it returns.
can someone explain it?

TIA

- Nicolaas


--
--.
--=<> Dr. Clue (A.K.A. Ian A. Storms) <>=-- C++,HTML/CSS,Javascript, TCP ...
--`
Aug 24 '05 #3
windandwaves wrote:
Hi Folk

I found the following function somewhere on the web. I am not sure how it
works, but I am sure that it is very useful:
It may be useful for particular circumstances related to legacy code and
support for old browsers. It is likely that better methods exist for
new applications.

Read the FAQ and look for DynWrite.

function getObj(name) {
if (document.getEl ementById){
if(document.get ElementById(nam e)) {
if(document.get ElementById(nam e).style) {
this.obj document.getEle mentById(name);
this.style document.getEle mentById(name);
The last two lines should have an equals sign '=' and the last one
probably should be a reference to the element's style object:

this.obj = document.getEle mentById(name);
this.style = document.getEle mentById(name). style;
}
}
}
else if (document.all){
this.obj = document.all[name];
this.style = document.all[name].style;
}
else if (document.layer s) {
this.obj = document.layers[name];
this.style = document.layers[name];
}
}

I guess that it finds out how the browser refers to elements with a specific
IDs and then returns them.
The function doesn't return anything.
However, I dont really understand "this." other
than that it refers to the function itself and how it or what it returns.
can someone explain it?


Read this bit of quirksmode (and anything else that takes your fancy,
it's all good):

<URL:http://www.quirksmode. org/js/this.html>

--
Rob
Aug 24 '05 #4
JRS: In article <0x************ *******@news.xt ra.co.nz>, dated Wed, 24
Aug 2005 17:25:01, seen in news:comp.lang. javascript, windandwaves
<wi*********@co ldmail.com> posted :
I found the following function somewhere on the web. I am not sure how it
works, but I am sure that it is very useful:

function getObj(name) {
if (document.getEl ementById){
if(document.get ElementById(nam e)) {
if(document.get ElementById(nam e).style) {
this.obj document.getEle mentById(name);
this.style document.getEle mentById(name);
}
}
}


It looks rather inefficient, as it does the search for name four
times. After removing the actual errors, consider something (untested)
along the lines of

function getObj(name) { var T
if (T = document.getEle mentById){
if (T = T(name)) {
if (T.style) {
this.obj T;
this.style T;
}
}
}
--
© John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 IE 4 ©
<URL:http://www.jibbering.c om/faq/> JL/RC: FAQ of news:comp.lang. javascript
<URL:http://www.merlyn.demo n.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demo n.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Aug 24 '05 #5
windandwaves wrote:
Thank you all for your comments. Much appreciated. I wrote this function:

function getObj (name) {
var T;
if (document.getEl ementById){
T = document.getEle mentById(name);
if(T) {
if(T.style) {
return T;
}
}
}
}

Which seems to serve my needs: return something if the element can be found
and the style can be changed.

Thank you again.

- Nicolaas
Aug 29 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
3162
by: Maciej Nadolski | last post by:
Hi! I can`t understand what php wants from me:( So: Cannot send session cache limiter - headers already sent (output started at /home/krecik/public_html/silnik.php:208) in /home/krecik/public_html/silnik.php on line 251 Line 208: print ( "error: " . mysql_error()); Line 251: session_register("uprawnienia", "zalogowany"); I can understand that sth, is wrong in line 251 after line 208 and it is logical to
2
1946
by: Abhish | last post by:
HI All ,:) I am a VC++ programmer,and some time My <b>Acumen</b> ask Microsofts VC++ (Visual Studio VC++ 6.0 )complier to complile my <b>senseless programs </b> ! :) <i><b> See what I have asked this time to compile !!..</b></i>
2
1509
by: Ravi Uday | last post by:
Hi, Can anybody explain this.. #define LIST_DESTROY(a) list_destroy(a) #define LIST_ENQUEUE(a, b, c) list_enqueue(a,b,c) #define LIST_REMOVE(a, b, c) list_remove(a,b,c) etc...
3
1461
by: Michael Tsai | last post by:
Hi, It said that IIS 6 use HTTP.sys as the front end for handling HTTP request, and pass ASP.NET requests to w3wp.exe, but after some simple experiments, I found the security settings (e.g. Authentication method) in IIS metabase is still applied before the HTTP request reach my ASP.NET application. Anyone one can explain this for me? or point to an article that explains: when a user requests an ASP.NET
1
1078
Creative
by: Creative | last post by:
Returning (by) Reference Consider the following function: float & min(float&a,float&b) { if(a>b) return a; else return b; }
6
1455
dmjpro
by: dmjpro | last post by:
how can i explain this ......... class S1 { static void Static() { System.out.println("Here i m ..."); } }
6
1515
by: PencoOdStip | last post by:
void print_msg( ostream &os, const string &msg ) { if ( msg.empty() ) // nothing to print; terminate function ... return; os << msg; } I don't understand the first line : void print_msg( ostream &os, const
18
2253
by: Jon Slaughter | last post by:
"Instead of just waiting for its time slice to expire, a thread can block each time it initiates a time-consuming activity in another thread until the activity finishes. This is better than spinning in a polling loop waiting for completion because it allows other threads to run sooner than they would if the system had to rely solely on expiration of a time slice to turn its attention to some other thread." I don't get the "a thread...
12
1490
by: raghukumar | last post by:
# include <iostream> class A { public: A() : i(1) {} int i; } ; class B: public A { public :
2
1201
by: gayathriram | last post by:
class test { static void show(params object b) { console.WriteLine(b.GetType().FullName); console.WriteLine(b.length); console.WriteLine(b); } public static void Main()
0
8349
marktang
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...
0
8275
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,...
0
8795
Oralloy
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...
0
7296
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5609
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();...
0
4143
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...
0
4281
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1906
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1585
bsmnconsultancy
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.