SVG + PHP + Javascript

I'm trying to create a PHP generated SVG but I'm allready stuck on displaying a SVG file with an Javascript in it. The javascript is a pan and zoom function.

The code is:

header("Content-Type: image/svg+xml");

    <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "">
    <svg xmlns="" xmlns:xlink="" version="1.1">
    <script xlink:href="SVGPan.js"/>
    <g id="viewport" transform="translate(200,200)">
    <polygon points="50,125 100,100 150,125 100,150" fill="green" stroke="black" stroke-width="1" />

When opening this in Internet explorer, I can pan, but I am unable to zoom.

When opening this in Google Chrome, I the script runs correctly, it displays, I can zoom and pan but I get an error message

error on line 10 at column 1: Extra content at the end of the document

I searched google for it, and stackoverflow but I cannot find a solution.

Can you please help me with this?

I see you are getting analytics code added which is causing extra output at the end of the file. Usually even free hosts will not put this on a file when it is getting served with the correct MIME type. You may need to ask their support how to get the image/svg+xml mime type served like the text/javascript mime type (i.e. without adding the analytics code). I have never used them, but cPanel and other popular management systems allow you to manage MIME types for many other reasons including this one.