jug Posted December 14, 2006 Share Posted December 14, 2006 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 advanceRegardsJug Quote Link to comment Share on other sites More sharing options...
sanfly Posted December 14, 2006 Share Posted December 14, 2006 you will need to post the script. There are some apects of javascript that need to be rewritten for firefox browsers Quote Link to comment Share on other sites More sharing options...
jug Posted December 14, 2006 Author Share Posted December 14, 2006 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 = NamePartdocument.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. Quote Link to comment Share on other sites More sharing options...
sanfly Posted December 14, 2006 Share Posted December 14, 2006 Also have you looked to see if any errors are coming up in the Firefox Javascript Console (TOOLS > Javascript Console) Quote Link to comment Share on other sites More sharing options...
jug Posted December 14, 2006 Author Share Posted December 14, 2006 Thanks for pointing that out. The error is:"window.event has no properties" on the first line of that function. Quote Link to comment Share on other sites More sharing options...
jug Posted December 14, 2006 Author Share Posted December 14, 2006 So anyone got any idea what I can use that will work in IE and Firefox? Quote Link to comment Share on other sites More sharing options...
sanfly Posted December 14, 2006 Share Posted December 14, 2006 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 Quote Link to comment Share on other sites More sharing options...
fenway Posted December 16, 2006 Share Posted December 16, 2006 You have to deal with window.event for IE, and just event ( the first parameter from every handler) for FF. Quote Link to comment Share on other sites More sharing options...
jug Posted January 22, 2007 Author Share Posted January 22, 2007 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 = NamePartdocument.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 advanceRegardsJug Quote Link to comment Share on other sites More sharing options...
mainewoods Posted January 22, 2007 Share Posted January 22, 2007 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.htmleverything your mother never told you about js events:http://www.quirksmode.org/js/introevents.html Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.