473,226 Members | 1,433 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,226 software developers and data experts.

this == document

how do you test if this is a reference to document?
this==document fails
Sep 27 '09 #1
6 1728
Markus
6,050 Expert 4TB
this === document ?

Not sure.
Sep 27 '09 #2
Dormilich
8,658 Expert Mod 8TB
Expand|Select|Wrap|Line Numbers
  1. test == document
worked for me.

another test would be
Expand|Select|Wrap|Line Numbers
  1. obj.toString().indexOf("HTMLDocument") != -1
Sep 27 '09 #3
Oops! I have two documents, on inside an iframe in one. is there a way to see if it is a Document? (typeof this returns object, I need to be more specific)
Sep 27 '09 #4
Dormilich
8,658 Expert Mod 8TB
see above


________________
Sep 27 '09 #5
rnd me
427 Expert 256MB
duck type it:
Expand|Select|Wrap|Line Numbers
  1. if (this.body && this.getElementsByTagName ){
  2.   alert("this quacks like a document!");
  3. }
Sep 28 '09 #6
Dormilich
8,658 Expert Mod 8TB
@rnd me
there are cases possible, where this is also true for custom objects (so take care of what you duck tape)
Sep 28 '09 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Rosinger | last post by:
Hi all, What is the preferred in term of browser copatability to get a reference to an element in the document in JavaScript? I am not sure about when to use document.all or document.layers or...
1
by: chirs | last post by:
Hi, Is there a difference between document.tagID and document.all.tagID. I've seen both like: document.myImage1.src = "nextImage2.jpg" and document.all.hot1.style.color= ... where hot1 is in...
3
by: Gary Mayor | last post by:
Hi, I'm re phrasing and earlier question as the earlier question doesn't make to much sense. I using document.onmousemove to move a <div line on the screen. At the moment if I click and move the...
7
by: Fendi Baba | last post by:
The function is called from opencalendar(targetfield). Thanks for any hints on what could be the problem. .............................................................. var...
10
by: InvisibleMan | last post by:
Hi, Thanks for any help in advance... Okay, I have the JS listed below that calls for the display of the (DIV) tag... cookie function not included, as don't feel its necessary but you'll get the...
9
by: alu | last post by:
Could someone explain the discrepancies within and between the stated definitions / usage of 'document.location' , 'document.URL' vs. their actual functionality? Should they be read-only when in...
2
by: Gulliver | last post by:
Gurus please help! Using VB.net I would like to do the following: 1. Open up a doc or rtf file in my application 2. Search through the text using keywords 3. Select portions of the text by...
13
by: RommelTJ | last post by:
Hi, My website (http://www.justiceinmexico.org/indextest.php) looks good in Firefox, but horrible in IE, and I think it's because of an error in the javascript of a free web ticker I got off the...
8
by: Mateusz Viste | last post by:
Hi, I am trying make some multimedia files playable from my website. So far, I am able to generate dynamically a new page containing the right <embed> section. However, when I load my script, it...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...

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.