Re: [WSG] DOM setAttribute in IE?

2004-08-19 Thread Justin French
Thanks to everyone for their help -- a few great solutions in no time at all. I finally stumbled on this via google, and it looks the goods so far: anchor.onclick = function() { ... } Since others have also recommended it, I'm pretty confident in it's use. And you're all right, we should be a

Re: [WSG] DOM setAttribute in IE?

2004-08-19 Thread Dan Webb
Also, if you assign the event using the way below (detailed by Mark) the keyword "this" would refer to the link so you could do this: anchor.onclick = function(){ window.open(this.href,'popupwindow','width=400,height=400,scrollbars=1,resizable=1'); return false; } rather than using event.srcEleme

RE: [WSG] DOM setAttribute in IE?

2004-08-19 Thread Patrick Lauke
I'd suggest using Scott Andrews' addEvent helper function (see http://www.scottandrew.com/weblog/articles/cbs-events) function addEvent(obj, evType, fn, useCapture){ if (obj.addEventListener){ obj.addEventListener(evType, fn, useCapture); return true; } else if (obj.attachEvent){ v

RE: [WSG] DOM setAttribute in IE?

2004-08-19 Thread Mike Foskett
IE does not like setAttribute onClick. I had a similar problem recently. I solved it by using the correct method first (as yours) then adding a function to deal with IE after it. function onclickIE(idAttr,handler,call){ if ((document.all)&&(document.getElementById)){idAttr[handler]=new

Re: [WSG] DOM setAttribute in IE?

2004-08-19 Thread Mark Lynch
Hi Justin, You can also use the simpler event model and add the event as follows: anchor.onclick = function(){ alert('anchor with rel clicked'); } This works in both IE and Mozilla. For more info on events in javascript the best resource I've found is http://www.quirksmode.org Cheers, Mark

RE: [WSG] DOM setAttribute in IE?

2004-08-19 Thread Eser 'Laroux'
You can use attachEvent method for this. But it's supported by Internet Explorer 6 only. -- test var anchors = document.getElementsByTagName('a'); for (var i=0; i

Re: [WSG] DOM setAttribute in IE?

2004-08-19 Thread Chris Blown
On Thu, 2004-08-19 at 16:22, Justin French wrote: > Can anyone either: > - suggest an alternate way to achieve this, or This might help http://msdn.microsoft.com/workshop/author/dhtml/reference/methods/attachevent.asp if (anchor.attachEvent) anchor.attachEvent("onClick", ); **