You cannot (easily) change this. The way to get a URL string from a General Link
field is via the GetFriendlyUrl()
method. It looks like this.
public string GetFriendlyUrl()
{
return new LinkUrl().GetUrl(new XmlField(this.InnerField, string.Empty), this.InnerField.Database);
}
Inside the LinkUrl
class, we find the GetJavaScriptUrl
method, and as you can see - the behaviour with forcing return false;
into the script is hard coded.
protected virtual string GetJavaScriptUrl(string url)
{
Assert.ArgumentNotNull((object) url, nameof (url));
if (!url.StartsWith("javascript:", StringComparison.OrdinalIgnoreCase))
url = "javascript:" + url;
return url + ";return false;";
}
So to do it, you would need to bypass this behaviour by making your own LinkUrl class and overriding this method.
public class MyLinkUrl : LinkUrl
{
public override virtual string GetJavaScriptUrl(string url)
{
string b = base.GetJavaScriptUrl(url);
return b.Replace(";return false;", ";");
}
}
And then generate your link without using the method directly on LinkField
;
return new MyLinkUrl().GetUrl(new XmlField(this.InnerField, string.Empty), this.InnerField.Database);
(code written directly in editor here, might have small syntax mishaps)