Loading ...
Sorry, an error occurred while loading the content.

59625Re: [svg-developers] Re: Create script element

Expand Messages
  • David Dailey
    Nov 29, 2007
    • 0 Attachment
      At 07:53 PM 11/28/2007, Domenico wrote:

      >David, Erik,
      >
      >Sorry for my post being a little unclear.
      >
      >svgdoc.createElementNS(svgNS,"script")
      >
      >works for Opera and Firefox. One question was if there's an
      >alternative that works for Safari and ASV as well.

      I also was unable to get it working in ASV, whence all my dabbling
      about with DOM. In IE/ASV I was able to confirm that the <script>
      element had been created, but I could not find any way to locate the
      functions within it, nor to run said functions. With a "normal"
      inline script, the text of the script including its function are
      available as the nodeValue of the relevant tag, but such does not
      seem to be for .es/.js files.

      The one workaround that comes to mind is the following -- embed the
      SVG in HTML and then load the script tag into HTML using DOM methods.
      The following works in IE, Opera, Safari and FF (with a simple
      alert("hello") statement in the alert.js file), so that could provide
      a workaround.

      Of course if browsers other than Opera would support foreignObject,
      then we could insert a tiny HTML object in the middle of our SVG
      instead of the other way around and use it to work around what
      appears (to me) to be an IE/ASV limitation.

      David

      <html>
      <head>
      <script>
      function build(){
      S=document.createElement("script")
      S.setAttribute("src","alert.js")
      document.documentElement.appendChild(S)
      }
      </script>
      </head>
      <body onload="build()">
      </body>
      </html>
    • Show all 9 messages in this topic