RemoveJavaScriptFromLinks
Contents
[
Hide
]HtmlFixedSaveOptions.RemoveJavaScriptFromLinks property
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 remove JavaScript from the links.
Document doc = new Document(MyDir + "JavaScript in HREF.docx");
HtmlSaveOptions saveOptions = new HtmlSaveOptions();
saveOptions.RemoveJavaScriptFromLinks = true;
doc.Save(ArtifactsDir + "HtmlSaveOptions.RemoveJavaScriptFromLinks.html", saveOptions);
Shows how to remove JavaScript from the links for html fixed documents.
Document doc = new Document(MyDir + "JavaScript in HREF.docx");
HtmlFixedSaveOptions saveOptions = new HtmlFixedSaveOptions();
saveOptions.RemoveJavaScriptFromLinks = true;
doc.Save(ArtifactsDir + "HtmlFixedSaveOptions.RemoveJavaScriptFromLinks.html", saveOptions);
See Also
- class HtmlFixedSaveOptions
- namespace Aspose.Words.Saving
- assembly Aspose.Words