"Kim" <No@thanks.com> wrote in message
news:43*********************@dread11.news.tele.dk. ..
Thanks that worked...
..for IE6, but not firefox
so..next question... can it be done in firefox?
"Evertjan." <ex**************@interxnl.net> skrev i en meddelelse
news:Xn********************@194.109.133.242... Jambalaya wrote on 28 sep 2005 in comp.lang.javascript:
I'm pretty sure the OP wants to generate 5 links. Your suggestion only
generates 1 link and then assigns 5 functions to it, each overwriting
the last.
Would this work?:
for(i=0; i<5; i++){
var theData = document.createElement('a');
theData.onmouseover = new Function("return " + i + ";");
...
}
Well yes, but returning a value to a <a> mouseover is not doing
anything.
Try this [ie6 tested]:
==========
<body>
<script type='text/javascript'>
for(i=0; i<5; i++){
myLink = document.createElement("a");
myLink.href = "http://www.cnn.com/";
myLink.innerHTML='CNN: '+i+'<br>'
myLink.onmouseover = new Function("alert('number: "+i+"');");
document.body.appendChild(myLink);
}
</script>
Try:
function createHREF(text,href)
{
var a = document.createElement("A")
document.body.appendChild(a)
var t = document.createTextNode()
t.data = text
a.href = href
a.onmouseover = gotoHREF
a.appendChild(t)
a.appendChild(document.createElement("BR"))
return a
}
function gotoHREF()
{
window.open(this.href) // Opens a new window.
//window.location = this.href
//Above opens in same window.
}
var hrefs = [ ["Yahoo","http://www.yahoo.co.uk"],
["Hotmail","http://www.hotmail.co.uk"] ]
for( var i = 0 ; i < hrefs.length ; i++ )
createHREF(hrefs[i][0],hrefs[i][1])
*************************************
I'm assuming that you're trying to get a mouseover event to change the URL
of the page. You didn't say.
--
Wayne
"Aka Dobbie the House Elf."