0

Let I've an image:

<img src="URL1"/>

I want that the src attribute will be URL1 only for Firefox browsers but URL2 for others browser. Is it possible to do?

  • See here [link](http://stackoverflow.com/questions/19352522/how-can-i-detect-browser-type-using-jquery). After detecting the browser you can set the image src accordingly. – tliokos Mar 07 '14 at 10:08
  • It is possible, although user agent detection is messy and generally discouraged. But there are JS libraries to do it. Basically you'd need to have an `onload` event which checks the browser and adjusts the image URL – lethal-guitar Mar 07 '14 at 10:08
  • possible duplicate of [In Javascript, how do I determine if my current browser is Firefox on a computer vs everything else?](http://stackoverflow.com/questions/2324944/in-javascript-how-do-i-determine-if-my-current-browser-is-firefox-on-a-computer) – aelor Mar 07 '14 at 10:12

2 Answers2

1

yes it's possible. Try this.

if (!(window.mozInnerScreenX == null); ) {
      // Change your image
  }
Rakesh Kumar
  • 2,705
  • 1
  • 19
  • 33
0

Check your browser agent by using Jquery

if(jQuery.browser.mozilla){
    // Change your image for URL1
}else{
    // Change your image for URL2
}
Nisam
  • 2,275
  • 21
  • 32