/    Sign up×
Community /Pin to ProfileBookmark

Equivalent in firefox?

Helllo, I wonder if you can help me. I know lots of people on here are firefox fans so I thought I would try to get my IE only pages working in firefox. I have mucked about with this function for hours and can’t get it to work. Can anyone tell me the firefox equivalent please.

function viewdetail(ProdID,Mine,ProdNo)
{
if (document.all)
{
window.event.returnValue = false;
var table = document.getElementById(‘StatusTbl’);
var rowNo = event.srcElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.rowIndex;
for (i=2;i<table.rows.length;i++)
{
if (i == rowNo)
{ table.rows[i].cells[11].firstChild.rows[0].cells[3].innerHTML = ‘<span><img src=”../../NewImages/MatrixPointer12x11.gif”></span>’; }
else
{ table.rows[i].cells[11].firstChild.rows[0].cells[3].innerHTML = ‘&nbsp;’; }
}
}
}

I know event.srcElement is IE only and I have been mucking around saying things like e.target.parentElement but can’t make it work.

Thanks for any input.

to post a comment
JavaScript

6 Comments(s)

Copy linkTweet thisAlerts:
@7studApr 17.2005 — 1) Don't ever post code again that isn't formatted :mad: , and use code tags: look on the bottom left of the page and click on the vb code link to see how.

2) Run this script in IE and FF, and see what happens:
window.onload=function()
{
if (document.all) alert("yep");
else alert("nope");
}
Copy linkTweet thisAlerts:
@WebskaterauthorApr 17.2005 — I know document.all is IE only - what I am struggling with is:

In IE you can get a reference to the object that triggered an event with:

event.srcElement

In Firefox I have seen examples where functions look like this:

function dosomething(e)

and a reference to the firing object seems to be:

e.target

In my code where I already have 3 parameters going into my function this does not work.
Copy linkTweet thisAlerts:
@7studApr 17.2005 — In my code where I already have 3 parameters going into my function this does not work.[/QUOTE] The only way you can send parameters to an event handler function is if the event handler is inline in the html. js wraps an inline event handler in a function with the event object as an argument to the function. So, an inline event handler function like so:

onclick="viewdetail(1,2,3)"

becomes:

onclick=function(event){ viewdetail(1,2,3) };

So, your function call can send the event along to your function:

onclick=function(event){ viewdetail(1,2,3, event) };

Then, you can change your function like so:
[CODE]viewdetail(ProdID,Mine,ProdNo, eventObj)
{
if(eventObj.target) //FF
alert(eventObj.target);
if(eventObj.srcElement) //IE
alert(eventObj.srcElement);

...
...
}[/CODE]
Copy linkTweet thisAlerts:
@WebskaterauthorApr 17.2005 — Thanks for your answers
Copy linkTweet thisAlerts:
@WebskaterauthorApr 18.2005 — Further to previous answers I tried this:

function changebk(overout,eventObj)

{

if (overout)

{

if(document.all)

{ event.srcElement.parentElement.className = 'buttonSR'; }

else

{ alert(eventObj.target); }

}

if (!overout)

event.srcElement.parentElement.className = 'buttonS';

}

this function changes the background color of a cell containing a hyperlink.

I am trying to get a reference to the object that called the function in Firefox - but when I mouseover the link - nothing happens.

In IE it does what it should. In Firefox the alert box is not appearing. It does appear if you put 'hello' in the alert. So Firefox does not seem to recognise eventObj.target

What am I doing wrong?

Help much appreciated.
×

Success!

Help @Webskater spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...