Ref: Find URLs in string and make as link using JavaScript in ASP.Net
this code not work my crome webbrowser
please more help
my code is.
public partial class Default2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Label1.Text = "I love asp county ilove my http://www.aspforums.net this is very good site of world my http://www.aspforums.net/ im allway visit https://www.aspforums.net/Threads/";
}
}
<%@ Page Title="" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" Runat="Server">
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
<script type="text/javascript">
function GenerateLinks(message) {
var urlRegex = /(((https?:\/\/)|(www\.))[^\s]+)/g;
return message.replace(urlRegex, function (url) {
var hyperlink = url;
if (!hyperlink.match('^https?:\/\/')) {
hyperlink = 'http://' + hyperlink;
}
return '<a href="' + hyperlink + '" target="_blank" >' + url + '</a>'
});
}
window.onload = function () {
document.getElementById('Label1').innerHTML = GenerateLinks(document.getElementById('Label1').innerHTML);
};
</script>
</asp:Content>