在新窗口中打开页面。 [英] Opening the page in new window.

查看:98
本文介绍了在新窗口中打开页面。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



代码看起来像..

.aspx.cs ::

--------

  if (ddl.SelectedIndex ==  10 
{
string url = ABC-2118(10-09).PDF;
Page.ClientScript.RegisterStartupScript( this .GetType(), open OpenWinLIP178( + url + ); true );
}



.aspx ::

-------

  var  url; 
函数OpenWinLIP178(url){
window.open(url,' LIP178'' height = 700,width = 850,left = 50,center = 100,top = 50,resizable = yes ,scrollbars = yes,toolbars = no,status = no');
}





此代码对我不起作用。抛出''ABC''这样的错误是未定义的。可以有人纠正这个代码吗?

解决方案

你好,



你可以这样使用:



 受保护 无效 button_Click( object  sender,EventArgs e)
{
// 打开页面中心的弹出窗口。
ScriptManager.RegisterStartupScript( this typeof string ), OPEN_WINDOW var Mleft =(screen.width / 2) - (760 / 2); var Mtop =(screen.height / 2) - (700/2); window.open(' your_page.aspx',null,'height = 700,width = 760,status = yes,toolbar = no,scrollbars = yes,menubar = no,location = no,top = \'+ Mtop + \',left = \\ \\'+ Mleft + \''); true );
}





也请参考以下链接。

打开一个新窗口

使用jquery打开一个新窗口



谢谢


Hi,
The code looks like..
.aspx.cs::
--------

if (ddl.SelectedIndex == 10)
           {
               string url="ABC-2118(10-09).pdf";
               Page.ClientScript.RegisterStartupScript(this.GetType(), "open", "OpenWinLIP178("+url+");", true);
           }


.aspx::
-------

var url;
  function OpenWinLIP178(url) {
      window.open(url, 'LIP178', 'height=700,width=850,left=50,center=100,top=50,resizable=yes,scrollbars=yes, toolbars=no, status=no');
  }



This code is not working for me.Its throwing the error like ''ABC'' is undefined.Can anyone correct this code?

解决方案

Hi,

you can use like this:

protected void button_Click(object sender, EventArgs e)
    {
        // open a pop up window at the center of the page.
        ScriptManager.RegisterStartupScript(this, typeof(string), "OPEN_WINDOW", "var Mleft = (screen.width/2)-(760/2);var Mtop = (screen.height/2)-(700/2);window.open( 'your_page.aspx', null, 'height=700,width=760,status=yes,toolbar=no,scrollbars=yes,menubar=no,location=no,top=\'+Mtop+\', left=\'+Mleft+\'' );", true);
    }



Refer the following links too.
open a new window
open a new window using jquery

Thanks


这篇关于在新窗口中打开页面。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆