Home › Forums › Back End › Javascript swap image doesn’t work inside PHP in Chrome browser › Re: Javascript swap image doesn’t work inside PHP in Chrome browser
This is more likely a caching issue. Clear your browser cache in Chrome and see if it works.
> Is it not compatible with javascript running inside PHP? Is that possible?
No, it’s not possible. Here’s the thing to understand:
(1) PHP happens *first*, **on the server**. Your script’s output *does not vary** across browsers.
**unless, of course, you intentionally detect the browser and serve different content.*
(2) JavaScript happens *later*, **on the client’s computer**. It *does not* run “inside” PHP (in fact, it has absolutely no idea that PHP even exists).
*****
Now, it *is* possible that Chrome and Firefox/IE are treating the same output differently. This is something you’ll be able to check without involving PHP: get your javascript working cross-browser first, then write your PHP to output the cross-browser version afterwards.