how to follow a javascript link programaticaly?

ido

Joined
Jun 17, 2005
Messages
1
Reaction score
0
Hi all this is my first post here :)

I would like to know something about using javascript programaticaly. The thing is i have this web site on which when i press a button it uses a function of javascript.. says exactly this in source

<a href="javascript:np('1')" ...

now when i am on that page and i type in my browsers comand line (or address field)
javascript:np('1')
it works just as if i would have pressed the button...

now my question is how can i do the same programaticaly... i tried using webrequest

HttpWebRequest req = (HttpWebRequest)WebRequest.Create(textBox1.Text);
req.Method = "Post";
string strPost = "javascript:np('1')";
req.CookieContainer = new CookieContainer();
req.ContentType ="application/x-www-form-urlencoded";
Encoding utf8 = new UTF8Encoding();
byte[] content = utf8.GetBytes(strPost);
req.ContentLength = content.Length;
using (Stream requestStream = req.GetRequestStream())
{
requestStream.Write(content, 0, content.Length);
}
HttpWebResponse Response = (HttpWebResponse)req.GetResponse();
StreamReader sr = new StreamReader(Response.GetResponseStream(),Encoding.GetEncoding(1252));
string t = sr.ReadToEnd();
sr.Close();
Response.Close();
richTextBox1.Text=t;

like this just to dump the source of the destination page into a textwindow but when i do
req.GetResponse();
i get an exception:
The remote server returned an error: (501) Not Implemented.

is there something im doing wrong and is there a way to do this?
I mean sure there is coz the browser does this but im just weak with javascript and new to web
programming.. so im asking for a little help :)

Thank you for your time
Ido
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top