2 Replies - 319 Views - Last Post: 21 November 2011 - 08:16 AM

#1 Infinite loop  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 04-April 11

Firefox 8.0 .replace not working on certain machines

Posted 17 November 2011 - 12:52 PM

I had a call today from a user using the latest release of Firefox 8.0. They where having issues and when I look into my java script Logs I found this error message "where.replace is not a function".

Old code: Which works correctly when I test it using the same browser on my development Box
textbox.setAttribute("onkeyup", "suggest(this,\"" + column + "\",\"" + table + "\",\"" + where.replace(/'/g, "<:-:>") + "\");");



The new code checks to see if the browser thinks replace is a function then recreates the function if it says it is not a function. I have test both paths and both give me correct results on my development box.

var safewhere = where;
if (where.replace) {
   var safewhere = where.replace(/'/g, "<:-:>")
}
else {
   while (safewhere.indexOf("'") != -1) {
   safewhere = safewhere.substring(0, safewhere.indexOf("'")) + "<:-:>" + safewhere.substring(safewhere.indexOf("'") + 1, safewhere.length)
   }
}
.
.
.
 textbox.setAttribute("onkeyup", "suggest(this,\"" + column + "\",\"" + table + "\",\"" + safewhere + "\");");
        



I just called the user and had them test page again and they got the same error. This may be a caching issue, but has anyone seen the original issue before or have any ideas why Firefox would say that replace is not a function one machine and not the other.

Is This A Good Question/Topic? 0
  • +

Replies To: Firefox 8.0 .replace not working on certain machines

#2 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 2899
  • View blog
  • Posts: 7,555
  • Joined: 08-June 10

Re: Firefox 8.0 .replace not working on certain machines

Posted 19 November 2011 - 08:13 AM

may not be directly linked to the problem … but why do you use setAttribute() to define an event handler? if you’re already in JS use the onevent property or (even better) event listeners (addEventListener())
Was This Post Helpful? 0
  • +
  • -

#3 Infinite loop  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 04-April 11

Re: Firefox 8.0 .replace not working on certain machines

Posted 21 November 2011 - 08:16 AM

It could probably be done that way. I was just running into compatibility issues during the original design (almost a year and a half ago so I don’t remember the exact issues with specific browsers). What the code actually does is create multiple auto complete textbox using AJAX that does not cause browser Post Backs. I was having problems finding one that would work the way I was wanting so I tried my hand at creating one.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1