1

Controller

public ActionResult GetCategories()
    {

        var htmlText = new StringBuilder();
        var scriptText = new StringBuilder();

        htmlText.Append("Hello world");
        scriptText.AppendFormat("document.write({0});", htmlText.ToString());
        var content = new ContentResult();
        content.Content = scriptText.ToString();
        return content;
    }

View

<script src="/Home/GetCategories" type="text/javascript" language="javascript"/>

It runs well on FF, but not in IE.

bobince
  • 528,062
  • 107
  • 651
  • 834
h3n
  • 5,142
  • 9
  • 46
  • 76
  • 2
    http://stackoverflow.com/questions/69913/why-dont-self-closing-script-tags-work ...in general, you should read Appendix C of the XHTML1 spec before using XHTML features like self-closing tags in old-school-HTML. http://www.w3.org/TR/xhtml1/#guidelines – bobince Dec 26 '09 at 14:05

1 Answers1

3

A script tag needs a closing tag to be compliant. IE actually obeys the standard in this respect while FF is more forgiving. Change your view to:

<script src="/Home/GetCategories" type="text/javascript" language="javascript">
</script>
tvanfosson
  • 524,688
  • 99
  • 697
  • 795