![]() |
Getting Error: is not a function when viewed in firefox - works in IE
Hi Guys,
Could someone please help me... I am trying to fix up the site www.thinkpharmacy.com.au On the right hand side of the home page there are some ads whcih are randomly generated. If you are browsing with Internet Explorer and you click one of these ads you get taken to that particular products page. everything works fine. The problem i am having is that if i am browsing the site using Firefox and i click one of the ads all i get the following error message... Error: gid("linkAds" + adsClicked).click is not a function Source File: http://www.thinkpharmacy.com.au/js/ads.js Line: 85 I cant understand why this is not working. Here is a copy of the script ads.js that is being called. javascript Code:
if anybody could help me out i would be very apprieciative. Thanks in advance, Almac007 |
I don't see how that can work in any browser, if that's the exact code you're using. You're missing curly brackets, and also the
function syntax for those classes are wrong. The syntax is as so:javascript Code:
Are you certain that's the precise code that you're using? |
Hi Wildhoney,
Thanks for getting back to me. Yeah that is the code cut and pasted from teh script. I was not the one who wrote it and am simply trying to fix it. When you say that function brackets are missing are you referring to var xmlHttpAds? and if so would it be something like var xmlHttpAds = { ...functions in here. } Thanks again for your help. almac007 |
Yep, that's the one! And also reverse the function and function names, as seen below. Hopefully this should get it working, but don't hesitate to re-paste the new code if it still doesn't work.
javascript Code:
Remember: functionName: function() :-) |
Hi Wildhoney,
Thanks for all your help with this. I have rewritten the code but now i cant get it to work in either IE or Firefox. I keep getting the follwoing error. Error: updateAds is not defined Source File: javascript:updateAds('73','0','/prodinfo.php?id=1252') Line: 1 Its probably something really simple :( here is a copy of the rewritten code. var xmlHttpAds = { var product = ''; var adsClicked = ''; var Urlproduct = ''; stateChangedAds: function() { if (xmlHttpAds.readyState==4) { openAds(); } }, GetxmlHttpObjectAds: function() { var xmlHttpAds=null; try { // Firefox, Opera 8.0+, Safari xmlHttpAds=new XMLHttpRequest(); } catch (e) { // Internet Explorer try { xmlHttpAds=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { xmlHttpAds=new ActiveXObject("Microsoft.XMLHTTP"); } } return xmlHttpAds; }, updateAds: function(id,product_id,Url) { adsClicked = id; xmlHttpAds = GetxmlHttpObjectAds(); var url = ""; // DMD - 20060626 - get the host info // and make the URL switch(window.location.hostname) { case 'www.thinkpharmacy.com.au': var serverNameURL = "https://www.thinkpharmacy.com.au"; break; case 'tpo.thinkpharmacy.com.au': var serverNameURL = "https://tpo.thinkpharmacy.com.au"; break; case 'www.productezine.com': var serverNameURL = "https://www.productezine.com/testserver/think"; break; default: var serverNameURL = ""; } var url=serverNameURL+"/ajax/updateAds.php?id="+id; product = product_id; xmlHttpAds.onreadystatechange=stateChangedAds; xmlHttpAds.open("GET",url,true); xmlHttpAds.send(null); Urlproduct = Url; }, openAds: function() { if(Urlproduct == ""){ gid("linkAdsProd"+adsClicked).click(); }else{ gid("linkAds"+adsClicked).click(); } } } thanks again for your help. |
I think it has more to do with the fact that you are using an object literal, yet are still trying to assign variables in a normal fashion.
javascript Code:
javascript Code:
|
Are you guys seeing the same code as me (in the original post)? I don't see a badly-written object, but a number of separate functions (4) and variables (4) in the global scope.
|
rofl, i must admit i only scan read it.
Sigh its been a long day. anyway the real error must be something to do with 'gid', is 'click' a property or a method? try knocking the '()' off the end. where is 'gid' defined? |
Hi Salathe,
So should i be using the code from the original post or use the code that i have rewritten in the above post? The code from the original post works in IE but not in firefox, where as the rewritten code does not work in either browser. :( Thanks for all your help guys. This forum is great! Cheers, Almac007 |
After looking over your code, i noticed that 'gid' returns a ref to and element via getElementById(), as a result you will need to re write this:
javascript Code:
Your old code should be fine. EDIT: Im assuming that the element returned by gid in this case is a link of some sort? if so you could do something like this javascript Code:
|
| All times are GMT. The time now is 04:04 AM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0