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
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
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
ler]=new
Function(call)}
}
Hope that helps
mike 2k:)2
mike foskett
[EMAIL PROTECTED]
http://www.webSemantics.co.uk
-Original Message-
From: Justin French [mailto:[EMAIL PROTECTED]
Sent: 19 August 2004 07:22
To: [EMAIL PROTECTED]
Subject: [WSG] DOM setAttribute in IE?
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
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
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", );
**
Here's a function:
function helpLinks()
{
if(!document.getElementsByTagName) return;
var anchors = document.getElementsByTagName("a");
for (var i=0; i
{
var anchor = anchors[i];
if (anchor.getAttribute("href") && anchor.getAttribute("rel") ==
"help")
{
anchor.setAttribute(
"on