How do I get the address / URL of a tag
< a href="js:redir(2)">
Through an HTML source?
NOTE: I tried to use the mshtml assembly, but it did not work either!
How do I get the address / URL of a tag
< a href="js:redir(2)">
Through an HTML source?
NOTE: I tried to use the mshtml assembly, but it did not work either!
You can use this example to deploy to your project , regular expression is used.
C #
private static void DumpHRefs(string inputString)
{
Match m;
string HRefPattern = "href\s*=\s*(?:[\"'](?<1>[^\"']*)[\"']|(?<1>\S+))";
try
{
m = Regex.Match(inputString, HRefPattern,
RegexOptions.IgnoreCase | RegexOptions.Compiled,
TimeSpan.FromSeconds(1));
while (m.Success)
{
Console.WriteLine(m.Groups[1]);
m = m.NextMatch();
}
}
catch (RegexMatchTimeoutException)
{
Console.WriteLine("The matching operation timed out.");
}
}
And to use the function just send the code HTML
as a parameter.
C #
string inputString = "My favorite web sites include:</P>" +
"<A HREF=\"http://msdn2.microsoft.com\">" +
"MSDN Home Page</A></P>" +
"<A HREF=\"http://www.microsoft.com\">" +
"Microsoft Corporation Home Page</A></P>" +
"<A HREF=\"http://blogs.msdn.com/bclteam\">" +
".NET Base Class Library blog</A></P>";
DumpHRefs(inputString);
Result
The project was building using console, just adapt the function to your project.
NOTE: You may need to include the reference below
using System.Text.RegularExpressions;
If I understand what you need, you can do it as follows:
<htmL>
<body>
A url completa da página atual é:
<script>
document.write(document.URL);
</script>
</body>
</html>
document.write(window.location.href)
Other ways:
document.write(window.location.protocol)
document.write(window.location.host)
document.write(window.location.pathname)
The code above will display:
"http"
"teste.com.br"
"login/index.html"