日期:2014-05-17 浏览次数:21035 次
string url = "http://www.baidu.com";
string script=string.Format(@"<script language='javascript' type='text/javascript'>
window.open('{0}','测试窗口','width=1366px,height=768px,directories=true,location=false,menubar=false,resizeable=false,scrollbars=yes,toolbar=false ');
</script>",url);
this.RegisterClientScriptBlock("Awoke", script);
------解决方案--------------------
Sorry,貌似看错了,是在窗体中,通过测试找到了一种方法,如下可以在窗体中打开可定义大小的新网页窗口,说白了,就是通过WebBrowser 调用触发页面中的事件并调用JS方法
可以试试看
string url = "http://www.baidu.com";
string script = @"<script language='javascript' type='text/javascript'>
function openUrl(url){
window.open(url,'测试窗口','width=400px,height=400px,directories=true,location=false,menubar=false,resizeable=false,scrollbars=yes,toolbar=false ');
}</script>";
WebBrowser wb = new WebBrowser();
//wb.DocumentStream=
wb.DocumentText = @"<html> <head>" + script + "</head><body><a id='a_open' onclick='javascript:openUrl(\"" + url + "\");'</body></html>";
wb.DocumentCompleted+=(o,args)=>{
HtmlDocument hDoc = wb.Document;
HtmlElement hEle = hDoc.GetElementById("a_open");
hEle.InvokeMember("click");
};