Jump to content

Firefox Problem


jug

Recommended Posts

This is not totally PHP but is related.

I have a page which works in IE but not in Firefox, the page basically does the following:

PHP Script outputs several images onto my page, and each of them have a unique id (from a mysql database) stored in the id tag. I have a javascript function which is called on mouse over of each image. This function gets the value of the id tag and display in a table below my images.

In IE, this works, but in Firefox, the data isn't displayed in the table when I hover over the images.

I'm guessing one of the features i'm using is not compatible with Firefox, can anyone tell me what it is and how I can overcome it.

Thanks in advance

Regards

Jug
Link to comment
Share on other sites

function GetDetails()
{
var DetailsAll = window.event.srcElement.id;
var WhereSpaceIs = DetailsAll.indexOf(" ")
var NamePart = DetailsAll.substr(0, WhereSpaceIs)
var AgePart = DetailsAll.substr(WhereSpaceIs)
document.getElementById("NameDisplay").innerHTML = NamePart
document.getElementById("AgeDisplay").innerHTML = AgePart
}

Basically I've got the name and age in the id tag and i'm separating them with a bit of string handling and displaying them in a table.
Link to comment
Share on other sites

I cant really test it out without your HTML too, so I suggest a [url=http://www.google.com/search?sourceid=navclient-ff&ie=UTF-8&rls=GGGL,GGGL:2006-22,GGGL:en&q=firefox+window.event]google search for "firefox window.event"[/url]

You will find google can help you out with most of these compatibilty issues, just search for firefox + the error
Link to comment
Share on other sites

  • 1 month later...
So can anyone suggest what the following code has to be to be cross-browser?

[b]Javascript Functions:[/b]

function GetDetails()
{
var DetailsAll = window.event.srcElement.id;
var WhereSpaceIs = DetailsAll.indexOf(" ")
var NamePart = DetailsAll.substr(0, WhereSpaceIs)
var AgePart = DetailsAll.substr(WhereSpaceIs)
document.getElementById("NameDisplay").innerHTML = NamePart
document.getElementById("AgeDisplay").innerHTML = AgePart
}

function GetDetailsRevert()
{
document.getElementById("NameDisplay").innerHTML = " "
document.getElementById("AgeDisplay").innerHTML = " "
}

[b]Each image has the following tags[/b]

<img id="' . $Variable .'" onMouseOver="GetDetails()" onMouseOut="GetDetailsRevert()" src="image.jpg">

[b]And the table where I display the data about the current image has these spans[/b]

<span id="NameDisplay">
<span id="AgeDisplay">




Thanks in advance

Regards

Jug
Link to comment
Share on other sites

to make the event information accessable cross browser, use this template:
[code]element.onclick = doSomething;

function doSomething(e) {
if (!e) var e = window.event;
// e gives access to the event in all browsers
}[/code]
http://www.quirksmode.org/js/events_access.html
everything your mother never told you about js events:
http://www.quirksmode.org/js/introevents.html
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.