Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Firefox issues

Status
Not open for further replies.

Trekmp

Programmer
Joined
Mar 7, 2006
Messages
4
Location
GB
Got some script that works fine in IE but not FF

Here the cut down version of HTML
<div id="jsBlock">
<ul>
<li><input type="checkbox" name="mesGroups[]"checked="checked" value="1"/>Group 1 <span class="sml">[<a href="#" name="viewContacts1" src="1" mth="vContacts">View contacts</a>]</span></li>
<li><input type="checkbox" name="mesGroups[]"checked="checked" value="3"/>Group 2 <span class="sml">[<a href="#" name="viewContacts3" src="3" mth="vContacts">View contacts</a>]</span></li>
</ul>
</div>

Here is the javascript
window.onload=function()
{
var d1=document.getElementById('jsBlock')
applyBehaviour(d1,MyHTC);
}

function MyHTC(aArgs)
{
this.inherit(HTC);
this.inherit(WebServiceConnector);
var oThis=this;

/*=== @desc : Internal entry point for class to initialize and execute itself ===*/
function init()
{
var myA=oThis.getElementsByTagName("a");
for(var i=0;i<myA.length;i++)
{
alert(myA.src); // FIREFOX doesn't / IE does and returns 1 and 3
alert(my.name); //FIREFOX/IE works fine gives me viewContacts1 and viewContacts3 like it should
}
}

init();
}
 
Is this copy-pasted? If so... your final alert is not alerting the array "myA", but alerting the array "my". Also, how is the MyHTC() function called? Specifically, what is the value for "aArgs" that is passed in to MyHTC()?

You say it doesn't work in FF - what debug information shows in the FF console?

Cheers,
Jeff

[tt]Jeff's Page @ Code Couch
[/tt]

What is Javascript? FAQ216-6094
 
Why are you alerting "myA" in one line, and "my" in the other? Where is "my" defined?

If "my" is defined elsewhere, can you paste the code? If it was a typo, then can you make sure you give us the real code, as there could be typos all over the place.

I also notice you refer to "HTCs" - AFAIK, these are IE-only behaviours (although I think there is some minor support in Fx, possibly).

You also don't say if the code is ever reaching that for loop for Firefox. Can you confirm this?

Dan

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Sorry no its not copy and paste just missed the A out of myA.

All the MyHTC code works fine or the rest of the script wouldn't work.

FF console doesn't show any errors,warning etc. The alert just returns undefined on the first alert in FF
 
Surely "myA.src" should be "myA.href", anyway?

And how can you say that "//FIREFOX/IE works fine gives me viewContacts1 and viewContacts3 like it should" when it clearly cannot have done with the mis-spelled array name?

Dan



[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Thanks Dan that .getAttribute sorted the problem for me. Haven't been doing JS all that long missed that one.

Thanks again
 
I'd still love to know how this worked for you:

Code:
alert(my[i].name);    //FIREFOX/IE works fine gives me viewContacts1 and viewContacts3 like it should

When there is no variable named "my".

Dan


[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
alert my.name was a typo when I wrote that code in, it should have been myA.name
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top