Is there a way to use c# to run a java script function on a website?
My code is below, basically at the moment it logs in by using a post form.
After it logs in i need it to run a java script function which is 'javascript:voteTab()';.
Thanks for your help guys.
you can run javascript with this in code behind,
ClientScript.RegisterStartupScript(typeof(Page), "key", "<script>voteTab();</script>");
EDIT:
using System.Web.UI; // for Page
using System.Web; //for HttpContext
Page page = HttpContext.Current.CurrentHandler as Page;
page.ClientScript.RegisterStartupScript(typeof(Page), "key", "<script>voteTab();</script>");
当然,在您的代码后面执行以下操作:
ClientScript.RegisterClientScriptBlock(this.GetType(), "key", "voteTab();", true);
I think you are trying to automate a website, rather than author one? You might want to take a look at Selenium which is a tool for automating websites.
As you are looking for a code solution I will also mention that selenium has .NET bindings.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.