We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Hyperlinks open in same tab when setting OpenInNewWindow with HTML conversion


we would like to convert Word documents to html (using the FixedHTML save format). In the html result we would like to open all external links in a new tab but internal links of the document to jump to in the same tab.

Our first approach was to iterate all hyperlinks and setting the OpenInNewWindow property to true. However, in the HTML result the links still open in the same tab. I think this is a bug and hyperlinks should be supposed to open a new browser tab if OpenInNewWindow is set.

We already found a workaround to set the Target to _blank instead. This also will open internal links in a new tab. In the documentation I found an example which checks if SubAddress != null. Is this a safe way to differentiate between external and internal links of the document or is there a better way to do this?

I attached you an example for the issue with the OpenInNewWindow property. You can reproduce the issue with the following code:

var lic = new License();

var doc = new Document(@"S:\tmp\links\test.docx");

// Prepare HTML Conversion
foreach (var hyperlinkField in doc.Range.Fields.Where(f => f.Type == FieldType.FieldHyperlink).Cast<FieldHyperlink>())
    hyperlinkField.OpenInNewWindow = true; // links in html still will open in same tab

    // workaround
    /*if (hyperlinkField.SubAddress == null) // <- is there a better way to differentiate between internal and external hyperlinks?
        hyperlinkField.Target = "_blank";*/

doc.Save(@"S:\tmp\links\out.html", SaveFormat.HtmlFixed);

Kind Regards,

example.zip (76.3 KB)


We have tested the scenario and have managed to reproduce the same issue at our side. For the sake of correction, we have logged this problem in our issue tracking system as WORDSNET-22145. You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.