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?

1
  • 1
    No. Javascript runs on the client, and images cannot contain Javascript. Commented Sep 9, 2013 at 21:19

1 Answer 1

2

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

7
  • Is there a way to send a request to a second page when the image is called? Commented Sep 9, 2013 at 21:20
  • You can attach onload handler to the image tag to see when the image is loaded. Commented Sep 9, 2013 at 21:22
  • The image being generated will be going into an email... So i can't put an onload to the img tag :( Commented Sep 9, 2013 at 21:23
  • @Brds: You can't run JS in emails, period. Commented Sep 9, 2013 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. Commented Sep 9, 2013 at 21:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.