HtmlFixedSaveOptions.RemoveJavaScriptFromLinks

HtmlFixedSaveOptions RemoveJavaScriptFromLinks property. Specifies whether JavaScript will be removed from links. Default is false.

Specifies whether JavaScript will be removed from links. Default is false.

public bool RemoveJavaScriptFromLinks { get; set; }

Remarks

If this option is enabled, all links containing JavaScript (e.g., links with “javascript:” in the href attribute) will be replaced with “javascript:void(0)”. This can help prevent potential security risks, such as XSS attacks.

Examples

Shows how to specify whether JavaScript will be removed from links in HtmlFixed format.

HtmlFixedSaveOptions htmlFixedSaveOptions = new HtmlFixedSaveOptions();
htmlFixedSaveOptions.RemoveJavaScriptFromLinks = true;

Converter.Create()
    .From(MyDir + "Simple.docx")
    .To(ArtifactsDir + "HtmlFixedSaveOptions.RemoveJavaScriptFromLinks.html", htmlFixedSaveOptions)
    .Execute();

See Also