1

If I hardcode a symbol the widget works fine. Any attemps I made such as using quotes/noquotes, or trying elements (I probably don't have enough knowledge) always comes back "something gone wrong". Does somebody have the solution, deleting the commented line and instead using var? (I want to prompt for sym, that is why it can not be hardcoded)

<script> var sym = "MSFT" </script>

<div class="tradingview-widget-container";>
  <script type="text/javascript" src="https://s3.tradingview.com/external-embedding/embed-widget-tickers.js" async>
  { "symbols": [
    { "title":       "MSFT", "proName": "MSFT"},
<!--{ "title":       "MSFT", "proName":   sym },  does not work -->
    { "title":        "SPY", "proName": "SPX" }
  ],
  "locale": "en"      }
  </script>  </div>

Running the snippet here gives a script error, but pasting it for example into https://codepen.io/pen/ or http://htmledit.squarefree.com/ or local html file runs just fine when deleting the commented line.

TonyT
  • 31
  • 1
  • 10
  • I don't have a fix, but here's what my digging turned up. The content of a script tag is ignored when the src is specified. It looks like it is accessible AS TEXT and not real JavaScript. So writing executable code wouldn't work. https://stackoverflow.com/questions/6528325/what-does-a-script-tag-with-src-and-content-mean – Gordon Kushner Apr 20 '18 at 16:38
  • That is a great explanation, and your link elaborates further. I still hope there could be some way to code and execute it as I would have many more applications than this quote example that I picked to illustrate. – TonyT Apr 20 '18 at 16:59

0 Answers0