JavaScript初步接触
在做一个项目中,接触到了JavaScript,主要是点击一个查询按钮然后弹出一个网页对话框,当在对话框中输入查询条件,点击确定后又返回到原来页面,得出查询结果。
页面如图:
在前台加了一个隐藏的DIV,里面放入两个控件。如下:
<div style="display:none">
<asp:TextBox ID="txtQueryWhere" runat="server"></asp:TextBox>
<asp:Button ID="btnquery" runat="server" Text="Button" OnClick="btnquery_Click" /></div>
前台查询按钮的代码如下:
<input id="Button2" type="button" value="查询" onclick="query()" />
当点击查询按钮时,转到query()函数——JavaScript:
<script language="javascript" type="text/javascript">
function query() {
window.showModalDialog("Query/DeviceQuery.aspx", window, "dialogWidth:700px;dialogHeight:400px;status:no;help:no;scroll:no");
}
</script>
于是就转到上图中的DeviceQuery页面。
按钮“确定”的代码为:
protected void btnOK_Click(object sender, EventArgs e)
{
string swhere = get_where().Replace("'", "\'");
Session["where"] = get_where();
string script = "window.returnValue='true'; window.dialogArguments.__doPostBack('btnquery', '');";
this.ClientScript.RegisterStartupScript(this.GetType(), "MPExecCommand", script, true);
script = "window.close();";
Common.ResponseScript(this.Page, script);
}
注意其中的script字段,里面的__doPostBack('btnQuery','')是返回到页面的btnquery按钮,执行它的Click事件。
相关文档:
貌似CSDN里的都是专业人士,高手可以掠过了,呵呵。
一下是源码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content ......
在javascript控制div之间的外边距时,代码写到
document.getElementById("").style.marginTop=20;
这个在IE浏览器中可以,但是在chrome中就不行,这个问题是应该
document.getElementById("").style.marginTop="20px";
各个浏览器中不同的问题要求不等对待,这些天学了div+css在设置各个浏览器是不同的配置,要针对每个 ......
引用类型通常叫做类(class),遇到引用值时,所处理的就是对象。
对象的创建:
var o = new Object();
如果没有参数可以省略括号,如:var o = new Object;
Object类:
&nb ......
delete只能删除开发者定义的属性或方法,原始的ECMAScript方法不能删除,因为不是开发者定义的,比如:toString()。
var o = new Object;
o.name = "Nicholas";
delete o.name;
&n ......