473,785 Members | 2,990 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

IE6: setInterval, this==window arrgh

At line
this.timerId = setInterval (function(){thi s.step()}, 100)
I get error dialog
Error:Object doesn't support this property or method.
If I change it to
this.timerId = setInterval (function(){thi s==window}, 100)
I see true, the sad fact that 'this' is window and not an anim.

What are some proper ways ?
I would like to avoid
this.timerId = setInterval ("Anim.step ( ' "+ this.o.id + " ' ) ", 100)
and avoiding the need for a global hash array (Anim.anims) to keep tracking
of my anims (key:td id, value:anim instance) that would have to be looked up
during each step.

--------
function X (s,cp) {
// cp - cell id prefix
document.write (
'<P>' + s + '</P>'
+'<TABLE BORDER="1">'
+ '<TR>'
+ '<TD ID="cell_1"'
+ ' onMouseOver="X. over(this)"'
+ ' onMouseOut="X.o ut(this)"'
+ '>this cell gets handled</TD>'
+ '<TD ID="cell_2"'
+ ' onMouseOver="X. over(this)"'
+ ' onMouseOut="X.o ut(this)"'
+ '>me too</TD>'
+ '</TR></TABLE>'
)

}

function X.over (o) { o.style.backgro und='Black' }
function X.out (o) {
o.anim = new Anim(o);
o.anim.start();
}

var Anim = function (o)
{
this.o = o
this.count=0
}
Anim.prototype. start = function ()
{
this.step();
this.timerId = setInterval (function(){thi s.step()}, 100)
}
Anim.prototype. step = function ()
{
this.count += 4
if (this.count > 15)
this.stop()
else {
level = anim.count * 16 - 1
anim.o.style.ba ckground = 'rgb('+level+', '+level+','+lev el+')'
}
}
Anim.prototype. stop = function ()
{
clearTimeout (this.timerId)
}
-----

--
Richard A. DeVenezia, subclassing Text Pad Control
http://www.devenezia.com/downloads/s...ndex.php?id=22
Jul 20 '05
10 7795
"Richard A. DeVenezia" <ra******@ix.ne tcom.com> writes:
As you stated prior it's not good practice or valid to add custom properties
to HTML tags, but how about post rendering of the HTML ? This works, but is
adding properties to existing window objects.

document.write( '<td id="foo" onmouseout="Out (this)"> .... </td>');
document.getEle mentById("foo") .adjunctData = { a:1, b:2, c:'I will appear',
d:4, e:5, f:6 }
This is quite legal.

The HTML specification is strict - it disallows attributes not in the
specification.

There is nothing in the DOM specification that recommends against
adding properties to DOM node objects. In Javascript, the DOM nodes
are just normal host objects, and they can allow you to add whatever
properties you want. However, as host objects, they could also prevent
it. Host objects are almost completely "implementa tion dependent" in
the ECMA 262 standard.
After a fair amount of experimentation , I found I could build the table
without document.writin g any HTML at all!
Not sure how cross-browser this is, but works for my windows IE6 and is spot
on for my personal style.
You use DOM methods to add rows and cells to the table. While not the
fastest method (I find using document.create Element("td") to be a
little faster in some browsers), it is still a very valid approach.

But, be careful:
document.write (
'<P>' + s + '</P>'
+'<TABLE ID="myTable" BORDER="1" CELLPADDING="10 "></TABLE>'
A valid table tag *must* include at least "<tr><td>" (and I would
include the end tags as well). If you care about invalid attributes,
you should also make sure that the HTML you document.write, is valid.
(I would also remove BORDER and CELLPADDING and use CSS instead).
table = window.myTable;
// is document.getEle mentById really needed if window.<id> or
window['<id>'] seems to always work ?
IE makes named elements available as global variables. Few other
browsers do.
row = table.insertRow (0);
cell = row.insertCell (0);

cell.innerHTML = 'Show me'
Now that you are using DOM, you might as well be consistent:

cell.appendChil d(document.crea teTextNode('Sho w me'));
cell.foo = '123'
cell.adjunctDat a = { a:1, b:2, c:'I will appear', d:4, e:5, f:6 }
cell.onmouseove r = function (EventSource) { X.over (this) } // during
invocation context this is the cell
}

X.over = function (o)
{
o.innerHTML = o.adjunctData.c


If we know that o contains only one text node:
o.firstChild.no deValue = o.adjunctData.c ;
Otherwise, we must clear out the contents of the node, and write
the new:
while(o.hasChil dNodes()) {
o.removeChild(o .lastChild);
}
o.appendChild(d ocument.createT extNode(o.adjun ctData.c));

Enjoy
/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit. html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #11

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

Similar topics

2
2265
by: Franklin P Patchey | last post by:
<P><A style="COLOR: rgb(0,0,0); FONT-SIZE: 80%; FONT-FAMILY: 'Comic Sans MS', cursive; TEXT- ALIGN: left" href="javascript:self.close();"><FONT size=4><STRONG>Close this window!</STRONG></FONT></A></P>
6
7329
by: rob | last post by:
Hi I'm trying to create a "roll-up" effect when a window loses focus and then "roll-down" when it regains focus. This statement works properly with every browser I can get my hands on EXCEPT WinIE6. WinIE6 says there's an error in the code, but the debugging info says the problem is on line 1 char 1, which are comments. <Body bgcolor='black' Text='#dbdbdb' onblur='window.resizeTo(150,150)'
5
9316
by: John A Grandy | last post by:
I have a js function that dynamically generates a block of html that includes an anchor tag : <a href="http://www.google.com" target="_blank" /> When the user clicks this link, the new IE6 browser window is full vertical size, but only half horizontal size (of available screen area). Starting iexplore.exe independently opens a full-size browser window.
3
5813
by: shawn | last post by:
Hi All Was trying to get this bit of code working (simplified of course) for (i=0;i<uuid_num;i++) { window.setInterval(InitMap(uuidValues), timePeriod); } Where uuid_num, uuidValues, timePeriod are defined above, along with function InitMap.
5
2216
by: mikewse | last post by:
I'm having a strange problem with window.name (from JavaScript) on *some* of our computers. OS is Windows 2000 so Internet Explorer version is IE6 sp1. I really need some help here... We are using window.name to set a hidden value in the browser that persists between page navs on our site. So the first page will set this value, giving the window a name, and this value can be used by the following pages when navigated to. Scenario: page1: ...
3
1409
by: satya61229 | last post by:
Hello experts Do you know what is the use of str = (this != window)?this:str; in a function. str is arg passed to that function. regards Satya Prakash
4
68049
by: Roger | last post by:
Hi, I am confused about the differences between this.window.focus(), window.focus(), and this.focus(). I want to use the calls in a <body onload="..."tag. What are the differences between these forms that may make one succeed and another fail? In particular, this.window.focus() fails in Opera 9.10 with an "object not found", and windows.focus() succeeds in Opera 9.10, Firefox 2.02, and IE 7.
4
3258
by: vunet | last post by:
Hello, My HTML form submits some values to a hidden iframe. However, this is done for file upload fields only. After file uploading is finished I am using this form to submit all other data (inputs, textareas, etc.) normally. The file upload mechanism is structured in the way that it sets form's enctype (multipart) and target to iframe dynamically and then resets to old values right after submit() method. This works ideally in most...
0
9480
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
10327
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
10151
jinu1996
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...
0
8973
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...
1
7499
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6740
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
5381
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
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3647
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.