HtmlLoadOptions.IgnoreNoscriptElements property

Gets or sets a value indicating whether to ignore <noscript> HTML elements. Default value is false.

public bool IgnoreNoscriptElements { get; set; }


Like MS Word, Aspose.Words does not support scripts and by default loads content of <noscript> elements into the resulting document. In most browsers, however, scripts are supported and content from <noscript> is not visible. Setting this property to true forces Aspose.Words to ignore all <noscript> elements and helps to produce documents that look closer to what is seen in browsers.


Shows how to ignore <noscript> HTML elements.

const string html = @"
          <meta http-equiv=""Content-Type"" content=""text/html; charset=utf-8"">
          <script type=""text/javascript"">
            alert(""Hello, world!"");
      <noscript><p>Your browser does not support JavaScript!</p></noscript>

HtmlLoadOptions htmlLoadOptions = new HtmlLoadOptions();
htmlLoadOptions.IgnoreNoscriptElements = ignoreNoscriptElements;

Document doc = new Document(new MemoryStream(Encoding.UTF8.GetBytes(html)), htmlLoadOptions);
doc.Save(ArtifactsDir + "HtmlLoadOptions.IgnoreNoscriptElements.pdf");

See Also