0

I have an HTML page with SVG diplayed as an img.

This page changes the displayed SVG file using d3: d3.select('img').attr('src', 'newFile.svg');

In other pages, I link to this HTML file and open it using window.open(...) which displays it with the "default" SVG file. Is there a way to set ('img').attr('src','...') from these other pages so that the required image is displayed instead?

  • When do you change the displayed SVG? Could you do it after loading the page? – Lars Kotthoff Aug 26 '13 at 20:43
  • @Lars - Yes. That is what I have tried calling so far. In Page0.html with the button I have `code .` But - can I achieve this from another file after calling window.open()? – user1610348 Aug 26 '13 at 20:48
  • It sounds like you would want to specify the image to show from the page you're redirecting from. You could pass this as a parameter to the target page. – Lars Kotthoff Aug 26 '13 at 21:03
  • @Lars - Thanks. Am I right that this would need server-side code rather than js or d3? – user1610348 Aug 26 '13 at 21:33
  • Not necessarily. You can pass parameters as part of the URL and extract them using Javascript. See for example [this question](http://stackoverflow.com/questions/979975/how-to-get-the-value-from-url-parameter). – Lars Kotthoff Aug 27 '13 at 08:15

0 Answers0