0

I need to place an entire javascript function in a div and show it for testing purposes, how can I accomplish this? I am doing this from code behind in asp.net

EDIT

<!-- Facebook Conversion Code for Website Purchase -->
<script type='text/javascript'>
(function() {
 var _fbq = window._fbq || (window._fbq = []);
  if (!_fbq.loaded) {
  var fbds = document.createElement('script');
  fbds.async = true;
  fbds.src = '//connect.facebook.net/en_US/fbds.js';
  var s = document.getElementsByTagName('script')[0];
  s.parentNode.insertBefore(fbds, s);
  _fbq.loaded = true;
  }
  })();
  window._fbq = window._fbq || [];
  </script>
chromeOne7
  • 23
  • 2
  • 7

1 Answers1

0

Edit: You need to do some trickery: How to show <div> tag literally in <code>/<pre> tag? Which says that you need to escape your < and > characters in your tag to &lt; and &gt; for them to show in the <pre>. The example below has been modified to show this.

You should try using the html <pre> tag, it's commonly supported and does exactly what you're asking for:

https://developer.mozilla.org/en-US/docs/Web/HTML/Element/pre

<pre>
  &lt;script type="text/javascript"&gt;
    console.log('hi');
  &lt;/script&gt;
</pre>

should show something like

<script type="text/javascript">
  console.log('hi');
</script>
Community
  • 1
  • 1
welegan
  • 2,845
  • 2
  • 13
  • 20