Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - converting a web site address to link
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

converting a web site address to link

 Post Reply Post Reply Page  12>
Author
moti View Drop Down
Groupie
Groupie


Joined: 07 September 2004
Status: Offline
Points: 73
Post Options Post Options   Thanks (0) Thanks(0)   Quote moti Quote  Post ReplyReply Direct Link To This Post Topic: converting a web site address to link
    Posted: 10 March 2005 at 9:52am
I have textarea
I want if user enter a web site address or email address after posting it with that text area it automatically converted to a link
for example  in this forum in editor if you type a link like this
 
after posting it automatically will change it to a link
ot if you type this
 

how can I do it with javascript or ASP scripts
 
Wink
Back to Top
Gullanian View Drop Down
Senior Member
Senior Member
Avatar

Joined: 04 January 2002
Location: England
Status: Offline
Points: 4373
Post Options Post Options   Thanks (0) Thanks(0)   Quote Gullanian Quote  Post ReplyReply Direct Link To This Post Posted: 10 March 2005 at 1:10pm
Read up on string manipulation in ASP.  Basically just search the string for things that look like web addresses.  Verify it, than manipulate it.
Back to Top
moti View Drop Down
Groupie
Groupie


Joined: 07 September 2004
Status: Offline
Points: 73
Post Options Post Options   Thanks (0) Thanks(0)   Quote moti Quote  Post ReplyReply Direct Link To This Post Posted: 10 March 2005 at 4:14pm
could you write the code?
I think we should use Replace function, Geek
Back to Top
Gullanian View Drop Down
Senior Member
Senior Member
Avatar

Joined: 04 January 2002
Location: England
Status: Offline
Points: 4373
Post Options Post Options   Thanks (0) Thanks(0)   Quote Gullanian Quote  Post ReplyReply Direct Link To This Post Posted: 10 March 2005 at 4:44pm
That's a lot of code.  'We' probably should use the replace function at some point.  I don't have the time sorry.  Take a look on google, it's out there somewhere.
Back to Top
tcampione View Drop Down
Newbie
Newbie
Avatar

Joined: 25 April 2004
Location: United States
Status: Offline
Points: 5
Post Options Post Options   Thanks (0) Thanks(0)   Quote tcampione Quote  Post ReplyReply Direct Link To This Post Posted: 12 March 2005 at 9:01pm
The basic idea is:
 
userAddress=request.form("address")
 
response.write ("<a href="  & useraddress & ">" &  useraddress & "</a>")
 
 
You are simply writing a standard formatted link using the formfield value.
 
Back to Top
Gullanian View Drop Down
Senior Member
Senior Member
Avatar

Joined: 04 January 2002
Location: England
Status: Offline
Points: 4373
Post Options Post Options   Thanks (0) Thanks(0)   Quote Gullanian Quote  Post ReplyReply Direct Link To This Post Posted: 12 March 2005 at 10:09pm
I think he was talking more along the lines of having a chunk of text like:

wefiwhfeiopwehf iphwfeih ihfwihewfpi hipfwepih www.drum-world.com fwihpwfe wfepiwef pijfwe wefpijwef

And then finding any hyperlinks and converting them to HTML
Back to Top
Mart View Drop Down
Senior Member
Senior Member
Avatar

Joined: 30 November 2002
Status: Offline
Points: 2304
Post Options Post Options   Thanks (0) Thanks(0)   Quote Mart Quote  Post ReplyReply Direct Link To This Post Posted: 13 March 2005 at 3:39am
it's in VB.NET but you should be able to convert it to asp 3.0, all it does is search a string using regular expressions for a link and then puts the relevant tags around it.



If Not IsDBNull(desc) Then
            Dim temp As String = desc

            Dim mc As MatchCollection = Regex.Matches(temp, "http://([\w-]+\.)+[\w-]+(/[\w- ./?%&amp;=]*)?", RegexOptions.IgnoreCase)

            For Each m As Match In mc
                If Not m.Value.Length > 40 Then
                &n bsp;   temp = temp.Replace(m.Value, "<a href=""" & m.Value & """ target=""_blank"">" & m.Value & "</a>")
                Else
                &n bsp;   temp = temp.Replace(m.Value, "<a href=""" & m.Value & """ target=""_blank"">Click here to visit link</a>")
                End If
            Next

            Return temp
        Else
            Return String.Empty
        End If


Back to Top
Bluefrog View Drop Down
Senior Member
Senior Member


Joined: 23 October 2002
Location: Korea, South
Status: Offline
Points: 1701
Post Options Post Options   Thanks (0) Thanks(0)   Quote Bluefrog Quote  Post ReplyReply Direct Link To This Post Posted: 14 March 2005 at 10:57pm
Mart did a good article on regular expressions in .NET at DevJunkies.com. Most of it is still applicable to ASP. I needed to do a task cleaning some text in .NET and used WWF code with a few tweaks. Very simple stuff.

Just read the article for a good overview.

Back to Top
 Post Reply Post Reply Page  12>

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.