Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!nuzba.szn.dk!pnx.dk!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: "Mel Smith" Newsgroups: comp.lang.javascript Subject: IE8 attachEvent problem Date: Sun, 20 Jan 2013 10:42:14 -0700 Lines: 80 Message-ID: X-Trace: individual.net mIKKQLwALXX4UFXZptcc3QlPwovAqKBi2Xn1/u5y1AxuLFacH+Q9ZTiQhcWE1ziDAZ Cancel-Lock: sha1:AlERH/KAXonjWgmy5jmH1PiDy7o= X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6157 X-RFC2646: Format=Flowed; Original Xref: csiph.com comp.lang.javascript:18163 Hi: Environment: As a client using an IE8 browser on a Win XP Pro (sp2) machine: Within the javascript code in my page there is a 'function remember()'. It is shown as --- the problem function --- below. The function 'remembers' where in a long table my user was viewing, so that when he 'returns' to the page, I position his viewport to the 'remembered' set of lines. It has worked fine for a long time but under IE7. Recently, I have started using IE8 as a testbed (in addition to Chrome and FF), and set IE8 to show me JS errors when viewing pages. When this remember function is called , IE8 shows a 'Type Mismatch' error at character 4 of the offending line (indicated by asterisks ("*****") below. When viewed with Chrome and FF, there is no problem because these browsers use addEventListener as the event handler (instead of attachEvent). I'm not a newbie, just a stupie, and would like to continue using this 'remember' function without the error. Hope that someone can help me fix this error on IE8 Thank you. -- Mel Smith Mesa, Arizona ------- the problem function ---------- function remember(e) { var targ,tid; if (!e) { var e=window.event; } if (e.target) { targ=e.target; } else if (e.srcElement) { targ=e.srcElement; } if (targ.nodeType==3) // defeat Safari bug { targ = targ.parentNode; } tid=targ.id; if (window.addEventListener) { window.addEventListener("load",document.getElementById(tid).scrollIntoView(),false) ; } else if (window.attachEvent) { // ********** next line shows a 'Type Mismatch' error at char(4) ******** window.attachEvent("onload",document.getElementById(tid).scrollIntoView()) ; } else { alert("c. No adding or attaching") ; window.onload = "document.getElementById(tid).scrollIntoView();" } return ; } -- Mel Smith