0

I have the following script:

      <script language="text/javascript">
        document.getElementById("eagle").src="http://path.com:8000/OA_HTML/1.gif";
      </script>

And html:

<img id="eagle" src="godlo.gif" width="60" height="60"/>

I won't JS to change path of the image, but stays the same. Why won't this work? In js fidle it works perfectly fine, so why won't this work in xslt? Maybe there is a wayaround?

UPDATE

I have edited this post to add xsl file. Although I don't think it is necessary here.

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml" version="1.0">
  <xsl:output method="html"/>
  <xsl:template match="*">
    <html>
      <head>
        <title>D</title>
      </head>
      <script language="text/javascript">
        document.getElementById("eagle").src="http://example.com:8000/OA_HTML/1.gif";
      </script>
      <body>
              <p  style="text-align:center;"><img id="eagle" src="1.gif" width="60" height="60"/></p>
</body>
    </html>
  </xsl:template>
tytan
  • 305
  • 1
  • 3
  • 12

2 Answers2

0

Your script does not know where is eagle, place your script below the img tag. Also need to change <script language="text/javascript"> to <script type="text/javascript">

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml" version="1.0">
<xsl:output method="html"/>
<xsl:template match="*">
  <html>
    <head>
      <title>D</title>
  </head>

  <body>
          <p  style="text-align:center;"><img id="eagle" src="1.gif" width="60" height="60"/></p>
</body>
<script type="text/javascript">
    var picurl = window.location.protocol+"//"+window.location.hostname+"/OA_HTML/godlo.gif/>";
    document.getElementById("eagle").src="http://example.com:8000/OA_HTML/1.gif";
  </script>
</html>
</xsl:template>
Ishank Gupta
  • 1,575
  • 1
  • 14
  • 19
0

Solution posted by @Ishank Gupta in comment was correct:

Changing <script language="text/javascript"> to <script type="text/javascript"> did the trick.

tytan
  • 305
  • 1
  • 3
  • 12