dotnet22
asked on
hyperlink without http://
When I try to launch a website through a server control hyperlink without the http:// portion it launches incorrectly. For instance if I launch www.cnn.com through
http://www.mysite.com/sites/mysites.aspx it launches as http://www.mysite.com/sites/www.cnn.com.
1) What I would like to know is why?
2) Is there a way to get it to launch properly without the http:// portion?
http://www.mysite.com/sites/mysites.aspx it launches as http://www.mysite.com/sites/www.cnn.com.
1) What I would like to know is why?
2) Is there a way to get it to launch properly without the http:// portion?
ASKER
Is there some javascript function that can be added as an attribute to the hyperlink to avoid this problem.
I would have thought there is, but it would be far more work to do that than to add the http:// in the code
what does the asp:hyperlink look like in your aspx/ascx page?
what does the asp:hyperlink look like in your aspx/ascx page?
ASKER
<a id="HyperLink1" href="www.cnn.com" target="_blank">HyperLink< /a>
without deliberately being facetious, why can't you do this
<a id="HyperLink1" href="http://www.cnn.com" target="_blank">HyperLink< /a>
<a id="HyperLink1" href="http://www.cnn.com" target="_blank">HyperLink<
ASKER
You could. It's just a matter of checking the value. I just wanted to bypass checking the url and whether it had http or not. So I'm assuming there is no javascript way to do this. Menaing haveing www.cnn.com work correctly without the http:// ?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
<a href="www.cnn.com">cnn</a>
if you click on this link from a site www.mysite.com, the link opened will be www.mysite.com/www.cnn.com
1. this isn't an asp.net problem so much as expected behaviour from your web browser.
2. you will need the http:// portion in place to open a site that is external to the site containing the link
I'm guessing you don't have the http:// portion because you are pulling the url back from a database or some such...? in this case you will need to add it yourself