1

I need to create a php script that renders an image... no problem.

However, what i'd like to do is have the image rendering script trigger some javascript code whenever the script is started up.

Is it possible to include javascript code within the image generating php script without it screwing up the image?

Brds
  • 1,035
  • 3
  • 17
  • 37

1 Answers1

2

Even if you add some javascript code into the image the browser will not run it.

Krasimir
  • 13,306
  • 3
  • 40
  • 55
  • Is there a way to send a request to a second page when the image is called? – Brds Sep 09 '13 at 21:20
  • You can attach *onload* handler to the image tag to see when the image is loaded. – Krasimir Sep 09 '13 at 21:22
  • The image being generated will be going into an email... So i can't put an onload to the img tag :( – Brds Sep 09 '13 at 21:23
  • @Brds: You can't run JS in emails, _period_. – SLaks Sep 09 '13 at 21:24
  • Right, I was trying to run JS in the script that generates the image used in the email, not in the email itself. I'm wondering if maybe a header() call in the script might do the job. – Brds Sep 09 '13 at 21:26
  • @Brds: That doesn't make any sense. JS only runs on the client, and email clients will never run any JS. – SLaks Sep 09 '13 at 21:37
  • I wasn't trying to run the javascript FROM the email. I was planning on putting a dynamic image src in the email (i.e. ) and then have that php script run some javascript... but it seems like it's a no go. – Brds Sep 09 '13 at 21:40