Q:我想去掉MultiLine(多層)Textbox的滾動條,如何做?
A:
change its style:
TextBox1.Style["overflow"] = "visible";
<textarea style="overflow:visible">..</textarea>
A2:textarea style="overflow-y:visible; border:0px; font-size:12px; font-family: 宋體 Fixedsys; line-height:150%; overflow:visible; border-width:0px; width:550px; height:40px"></textarea>
///
html頁面技巧大全
1. oncontextmenu="window.event.returnValue=false" 將徹底屏蔽鼠標右鍵
<table border oncontextmenu=return(false)><td>no</table> 可用于Table
2. <body onselectstart="return false"> 取消選取、防止復制
3. onpaste="return false" 不準粘貼
4. oncopy="return false;" oncut="return false;" 防止復制
5. <link rel="Shortcut Icon" href="favicon.ico"> IE地址欄前換成自己的圖標
6. <link rel="Bookmark" href="favicon.ico"> 可以在收藏夾中顯示出你的圖標
7. <input style="ime-mode:disabled"> 關閉輸入法
8. 永遠都會帶著框架
<script language="JavaScript"><!--
if (window == top)top.location.href = "frames.htm"; //frames.htm為框架網頁
// --></script>
9. 防止被人frame
<SCRIPT LANGUAGE=JAVASCRIPT><!--
if (top.location != self.location)top.location=self.location;
// --></SCRIPT>
10. <noscript><iframe src=*.html></iframe></noscript> 網頁將不能被另存為
11. <input type=button value=查看網頁源代碼
onclick="window.location = ''view-source:''+ ''http://www.csdn.net/''">
12. 怎樣通過asp的手段來檢查來訪者是否用了代理
<% if Request.ServerVariables("HTTP_X_FORWARDED_FOR")<>"" then
response.write "<font color=#FF0000>您通過了代理服務器,"& _
"真實的IP為"&Request.ServerVariables("HTTP_X_FORWARDED_FOR")
end if
%>
13. 取得控件的絕對位置
//Javascript
<script language="Javascript">
function getIE(e){
var t=e.offsetTop;
var l=e.offsetLeft;
while(e=e.offsetParent){
t+=e.offsetTop;
l+=e.offsetLeft;
}
alert("top="+t+"\nleft="+l);
}
</script>
//VBScript
<script language="VBScript"><!--
function getIE()
dim t,l,a,b
set a=document.all.img1
t=document.all.img1.offsetTop
l=document.all.img1.offsetLeft
while a.tagName<>"BODY"
set a = a.offsetParent
t=t+a.offsetTop
l=l+a.offsetLeft
wend
msgbox "top="&t&chr(13)&"left="&l,64,"得到控件的位置"
end function
--></script>
14. 光標是停在文本框文字的最后
<script language="javascript">
function cc()
{
var e = event.srcElement;
var r =e.createTextRange();
r.moveStart(''character'',e.value.length);
r.collapse(true);
r.select();
}
</script>
<input type=text name=text1 value="123" onfocus="cc()">
15. 判斷上一頁的來源
asp:
request.servervariables("HTTP_REFERER")
java script:
document.referrer
16. 最小化、最大化、關閉窗口
<object id=hh1 classid="clsid:ADB880A6-D8FF-11CF-9377-00AA003B7A11">
<param name="Command" value="Minimize"></object>
<object id=hh2 classid="clsid:ADB880A6-D8FF-11CF-9377-00AA003B7A11">
<param name="Command" value="Maximize"></object>
<OBJECT id=hh3 classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11">
<PARAM NAME="Command" VALUE="Close"></OBJECT>
<input type=button value=最小化 onclick=hh1.Click()>
<input type=button value=最大化 onclick=hh2.Click()>
<input type=button value=關閉 onclick=hh3.Click()>
本例適用于IE
17.
<%
''定義數據庫連接的一些常量
Const adOpenForwardOnly = 0 ''游標只向前瀏覽記錄,不支持分頁、Recordset、BookMark
Const adOpenKeyset = 1 ''鍵集游標,其他用戶對記錄說做的修改將反映到記錄集中,但其他用戶增加或刪除記錄不會反映到記錄集中。支持分頁、Recordset、BookMark
Const adOpenDynamic = 2 ''動態游標功能最強,但耗資源也最多。用戶對記錄說做的修改,增加或刪除記錄都將反映到記錄集中。支持全功能瀏覽(ACCESS不支持)。
Const adOpenStatic = 3 ''靜態游標,只是數據的一個快照,用戶對記錄說做的修改,增加或刪除記錄都不會反映到記錄集中。支持向前或向后移動
Const adLockReadOnly = 1 ''鎖定類型,默認的,只讀,不能作任何修改
Const adLockPessimistic = 2 ''當編輯時立即鎖定記錄,最安全的方式
Const adLockOptimistic = 3 ''只有在調用Update方法時才鎖定記錄集,而在此前的其他操作仍可對當前記錄進行更改、插入和刪除等
Const adLockBatchOptimistic = 4 ''當編輯時記錄不會被鎖定,而更改、插入和刪除是在批處理方式下完成的
Const adCmdText = &H0001
Const adCmdTable = &H0002
%>
18. 網頁不會被緩存
HTM網頁
<META HTTP-EQUIV="pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache, must-revalidate">
<META HTTP-EQUIV="expires" CONTENT="Wed, 26 Feb 1997 08:21:57 GMT">
或者<META HTTP-EQUIV="expires" CONTENT="0">
ASP網頁
Response.Expires = -1
Response.ExpiresAbsolute = Now() - 1
Response.cachecontrol = "no-cache"
PHP網頁
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");
19. 檢查一段字符串是否全由數字組成
<script language="Javascript"><!--
function checkNum(str){return str.match(/\D/)==null}
alert(checkNum("1232142141"))
alert(checkNum("123214214a1"))
// --></script>
20. 獲得一個窗口的大小
document.body.clientWidth,document.body.clientHeight
21. 怎么判斷是否是字符
if (/[^\x00-\xff]/g.test(s)) alert("含有漢字");
else alert("全是字符");
22.TEXTAREA自適應文字行數的多少
<textarea rows=1 name=s1 cols=27 onpropertychange="this.style.posHeight=this.scrollHeight">
頁面很簡單,就是一個文本框keyword和一個圖片按鈕doit,功能是,點擊doit這個圖片彈出新窗口顯示查找的結果。
我原來做法是在按鈕的doit_click過程中使用response.write("<script>window.open('search.aspx?keywork="&keyword.text&"',_blank)</script>")
功能是實現了,可就是會被廣告攔截程序攔掉。
后來又使用onclick="window.open('search.aspx')"的方式來打開,用session("keyword")來傳遞參數。但碰到個問題:我在doit_click里給session("keyword")賦值,可oncick比doit_click先執行,即先打開新頁面,再給session賦值,這就使查找的關鍵字是前一次輸入的keyword。又不能解決問題。
A:
在onclick的里面獲取文本框的值,然后作為url參數傳到search.aspx
var keyword = document.getElementById('Keyword');
window.open('search.aspx?Keyword=' + encodeURI(var.value));
////
Q:
datagrid超鏈接打開定制新窗口的問題時出現的錯誤????
DataNavigateUrlFormatString="Javascript:window.open('CourseDetails.aspx?CourseCode={0}','','width=600,height=400,toolbar=0,menubar=0')"
但點擊鏈接后除了彈出想要得窗口外,另彈出一個窗口。該窗口頁面只有[object]字樣,窗口標題為Javascript:window.open('CourseDetails.aspx?CourseCode={0}','','width=600,height=...
A:
private void projectinfo_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if(e.Item.ItemType==ListItemType.Item||e.Item.ItemType==ListItemType.AlternatingItem)
{
//邦定連接字段
string NavigaterUrl = PargetUrl+"?id="+e.Item.Cells[1].Text;
//定制客戶端屬性
StringBuilder ClientTitle = new StringBuilder();
ClientTitle.Append("this.bgColor='#ffefe5'");
e.Item.Attributes.Add("onmouseover",ClientTitle.ToString());
e.Item.Attributes.Add("onmouseout","this.bgColor='#ffffff'");
//e.Item.Cells[0].Attributes.Add("onclick","javascript:show()");
e.Item.Attributes.Add("onclick","javascript:window.open('"+NavigaterUrl+"','MainFrameSetMain'),this.bgColor='#C1D2EE'");
//不換行顯示
}
}
///
誰幫我用javascript寫一個打開一個340*340的新窗口的程序。
A:window.open('a.aspx','','toolbar,menubar,scrollbars,resizable,status,location,directories,copyhistory,height=340,width=340')
window.open('a.aspx','','toolbar=no, menubar=no, scrollbars=no, resizable=1, location=no, status=no',height=340,width=340');
所有的彈出廣告都是這樣做的,看看新浪的主頁就知道了。
<script language=javascript>
<!-- Hide
var newWindow = null
function windowOpener(loadpos)
{
if (! newWindow || newWindow.closed)
{
newWindow = window.open(loadpos,"surveywin","toolbar,resizable,scrollbars,dependent,width=400,height=280");
}else
{
newWindow.focus();
}
}
//end-->
</SCRIPT>
///
Q:
請教關于window.open的問題。我在驗證后用window.open打開了新窗口,怎么把現在的窗口關閉呢?謝謝! Response.Write("<script language='javascript'>window.open('SystemConfig/Index.aspx','','width=1012,height=710,left=0,top=0,resizable=yes');window.close();</" + "script>");
這樣用window.close()會彈出提示框,提示是不是關閉,請問怎么才能不提示就關閉呢?或是通過別的方法。謝謝@!
A:
window.opener=null;
window.close();
A2:
Response.Write("<script language='javascript'>window.open('SystemConfig/Index.aspx','','width=1012,height=710,left=0,top=0,resizable=yes');window.opener=null;window.close();</" + "script>");
////
open
打開一個新窗口,并裝載URL指定的文檔,或裝載一個空白文檔,如果沒提供URL的話。
適用于
窗口
語法
widow = object.open([URL[,name[,features[,replace]]]])
參數 說 明
URL 規定要顯示的文檔URL的串。如果規定了URL,就顯示帶有about:blank的新窗口。name選項。規定窗口名字的串。這個名字用于FORM上的或用于A。選項。規定顯示窗口裝飾物的串。
下面的表列出所支持的特征語法說明
fullscreen={yes | no | 1 | 0 }規定是在全屏幕上還是在正常窗口中顯示瀏覽器。默認值是no。使用全屏幕模式要當心。因為這種模式把瀏覽器的標題欄和菜單都隱蔽起來,你應當提供一個按鈕或其他線索,幫助用戶關閉這個窗口。Alt+F4也關閉這個新窗口。
channelmode= { yes | no | 1 | 0 }規定是否以劇場模式顯示窗口,并顯示通道帶。
toolbar={yes | no | 1 | 0 }規定是否顯示瀏覽器toolbar、makingbutton,例如可用的Back、Forward、Stop
location={yes | no | 1 | 0 }規定是否顯示用于把URL直接鍵入瀏覽器的輸入字段
directories={yes | no | 1 | 0 }規定是否添加目錄按鈕,默認值是no
status={yes | no | 1 | 0 }規定是否在窗口底部添加狀態條。默認是no
menubar={yes | no | 1 | 0 }規定是否顯示菜單條。默認是no
scrollbars={yes | no | 1 | 0 }規定是否顯示水平和垂直滾動條。默認是no
resizeble={yes | no | 1 | 0 }規定是否在窗口的角落上顯示重定尺寸處理程序
width=number設置窗口的寬度,單位是像素
height=number規定窗口的高度,單位是像素。最小值是100
top=number規定頂位置,單位是像素。這個值是相對于屏幕的左上角的
left=number規定左位置,單位是像素。這個值是相對于屏幕左上角的
replace選項。是一個布爾值,規定要裝入新頁面上的URL是否在窗口瀏覽歷史中要建立一個新條目,或者取代瀏覽歷史中的當前條目。如果是真,就不建立新歷史條目。
返回值
返回一個到新窗口的引用。
使用這個引用,在新窗口上腳本屬性和方法上。說明新窗口的一個名字可以作為一種形式或一個A元素的目標。按照默認,open( )方法創建一個窗口。這個窗口有默認寬度和高度、標準的菜單、工具條,和其他Internet Explorer特征。你可以使用特征參數改變這組特征。這個參數是由一個或多個特征設定組成的串。替換參數便控制新窗口是否放到瀏覽器歷史列表中。作為例子,下邊創建一個包含Sample.htm的新窗口。新窗口為200乘400像素,有一個狀態條,但是沒有工具條、菜單或地址字段。
window.open("ample.html",null,"height=200,width=400,status=yes,toolbar=no,menubar=no,location=no");
/////Q:
在datagird中,在鏈接字段上面點擊彈出窗口,up者有分
<asp:HyperLinkColumn Text=">>GO" DataNavigateUrlField="OperId" DataNavigateUrlFormatString="javascript:showModalDialog()"></asp:HyperLinkColumn>
這樣可以實現彈出窗口,請問用window.open,和showModalDialog怎么實現?然后如何新窗口中彈出對話框?
A:
後臺:
for (int j = 0; j < dg.Items.Count; j ++)
{
str1="MM_openBrWindow('06digital_view.aspx?e='"+dg.DataKeys[j].ToString()+",'作品瀏灠','width=550,height=400')";
hlink = (HyperLink)dg.Items[j].Cells[4].FindControl("hlink");
hlink.Attributes.Add("OnClick",str1);
}
前臺:
<meta http-equiv="Content-Type" content="text/html; charset=big5">
<script language="JavaScript">
<!--
function MM_openBrWindow(theURL,winName,features) { //v2.0
window.open(theURL,winName,features);
}
//-->
</script>
A2:
如果用DataNavigateUrlFormatString彈出窗口效果不好的話,可以使用以下方法:
<columns>
<asp:TemplateColumn runat="server">
<itemtemplate> <a href='' onClick='return f_open1("<%# DataBinder.Eval(Container.DataItem,"filename")%>")'><%# DataBinder.Eval(Container.DataItem,"title") %></a>
</itemtemplate>
<SCRIPT language="JavaScript">
function f_open1(name)
{
window.open('infoshow.aspx?name='+name,'','scrollbars=yes,toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=yes,top=0, left=0,width=480%,height=400%');
return false;
window.opener=null;
window.close();
}
</SCRIPT>
//
我的在aspx里寫,不在.cs里
<asp:HyperLinkColumn Text=">>GO" NavigateUrl="javascript:window.open('a.aspx?id=<%# DataBinder.Eval(Container.DataItem,"OperId")%>','','toolbar=no');"></asp:HyperLinkColumn>
<asp:HyperLinkColumn Text=">>GO" DataNavigateUrlField="OperId" DataNavigateUrlFormatString="javascript:window.open('a.aspx?id={0}','','toolbar=no');"></"></asp:HyperLinkColumn>
/////
用datagrid的超級鏈接打開新頁面,在新頁面修改數據后怎么刷新父頁面?
我使用了Response.Write("<script language='javascript'>window.parent.location.reload();</script>");
卻不好用?為什么?
Response.Write("<script language='javascript'>self.close();</script>");
可以執行!
A1:
如果你是用Javascript的window.open()方法打開的,可以試試:
window.opener.location.reload();
如果你是用超鏈接 <a href="mypage.aspx" target="_blank">在新窗口打開</a> 這樣打開的,那么兩個窗口之間沒有任何關系,所以無法實現刷新打開新頁面的窗口的要求。
A2:
使用Response.Write("<script language='javascript'>window.opener.location.href = window.opener.location.href;window.close();</script>");
A2:
這個問題,呵呵~~~~其實是老問題了~~~~~
1 首先如果你父頁面中,提交過,有本頁提交,即IsPostBack = ture .那么子窗體中用javaScript 的
window.opener.location.reload();方法就會出現IE討厭的網頁刷新重試按鈕.
2 .除非你父窗體中沒有本頁提交,都是通過href = ....._blank 出去的,在子頁面中使用
reload()是沒有問題.
A3:
這個問題我這幾天在研究,關于刷新父頁面的法子是可以辦到的。我是使用打開模態對話框提交自動關閉然后自動刷新父頁面。
因為我不知道你說的“用datagrid的超級鏈接”這個鏈接文本是數據綁定的還是固定的鏈接。這兩個鏈接要用到不同的事件處理模塊。
假設你的這個鏈接是你的DataGrid的第三列,是修改按鈕。代碼如下:
html代碼中加入:
<script language="javascript">
<!--
function OpenEditWin(strID)
{
var url; // 定義你要打開的頁面位置,假設是editdata.aspx
url = 'editdata.aspx?ID=" + strID;
var me;
// 把父頁面窗口對象當作參數傳遞到對話框中,以便對話框操縱父頁自動刷新。
me = window;
// 打開對跨框的第三個參數要設定與editdata.aspx一樣的大小。
window.showModalDialog(url,me,'dialogWidth:580px;dialogHeight:520px;help:no;status:no')
}
//-->
</script>
上面的js代碼是讓DataGrid的超鏈接調用的,參數是查詢字符串關鍵字,讓editdata.aspx獲得。
然后是后臺代碼:
假設使用<asp:HyperLink)標簽,name 是lnkEdit
首先必須在“Web 窗體設計器生成的代碼”的“InitializeComponent()”中加入DataGrid的事件處理程序(DataGrid名稱為MyDataGrid):
this.MyDataGrid.ItemDataBound += new DataGridItemEventHandler(this.MyDataGrid_ItemDataBound);
然后vs.net會自動生成一個MyDataGrid_ItemCreated方法,在里面添加:
private void MyDataGrid_ItemDataBound(object sender, DataGridItemEventArgs e)
{
if(e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
for(int i=0;i<MyDataGrid.Items.Count;i++) // 循環查找所有DataGrid所有行
{
HyperLink lnk;
lnk = (HyperLink)MyDataGrid.Items[i].Cells[2].FindControl("lnkEdit");
// 現在,找到了鏈接,可以加東西了。
// 首先獲得記錄主健
string str = MyDataGrid.DataKeys[i].ToString();
lnk.NavigateUrl = "#"; //表示內部鏈接
// 注意,下面這行代碼調用寫好的js,并且把參數傳遞進去。
lnk.Attributes.Add("onclick","javascript:OpenEditWin('" + str + "')");
}
}
上面的方法就是在DataGrid數據綁定后,強行修改鏈接字段的內容。
下面是dataedit.aspx的內容:
這個頁面實際上是一個模態對話框,這種對話框要注意兩個難點:
1 提交自動打開新窗口
2 對父窗口的引用無效(即使用window.opener操作無效)
接上:
解決第一個問題花了我好長時間,我在網上查找了好多資料,解決辦法無非是下面兩種:
1 在<head></head>內加入:<base target="_self">
2 在打開的模態對話框中使用<iframe>框架,在框架內使用.aspx文件,文件的提交target使用<iframe>的名稱。即模態對話框不直接打開.aspx文件,而是打開含有框架的文件,在框架里面使用aspx文件。
以上兩種辦法我都用了,不管用。第一種辦法我用了,表單提交的時候仍然打開新窗口。第二種辦法也不可取,因為我要向模態對話框打開的文件傳遞查詢字符串,而這個文件無法把這個字符串傳遞到框架內包含的文件中。
我解決這個問題還是使用js腳本,模態對話框直接打開.aspx文件,正常使用.aspx?ID=XXX這樣的方式,在這個.aspx文件中加入js代碼:
<script language="javascript">
<!--
function onsubmit() // 定義表單提交事件發生的時候怎樣處理
{
document.Form1.target="_self";
}
//-->
</script>
上面的代碼就是當表單提交的時候強制提交目標為本頁,即使用對話框處理提交,而不是打開新頁面。我注意到了,所有模態對話框自動打開新頁面都是標單提交造成的。
然后就可以加入<asp:button>控件,處理數據庫操作了,操作完畢以后,與貼主一樣,向頁面寫入js代碼,關閉本對話框并刷新父頁面
后臺代碼
private void btnSubmit_Click(object sender,EvengArgs e)
{
// 前面是數據庫操作
// 成功后,寫
Response.Write("<script language=\"javascript\">\r\n");
Response.Write("<!--\r\n");
Response.Write("if(dialogArguments != null){\r\n");
// 注意上面的dialogArguments,就是父頁面showModalDialog()的第二個參數。
// 就是父頁面的window對象引用。
Response.Write("dialogArguments.location.reload(true);\r\n");
// 上面就是刷新父頁的代碼,相當于在父頁上使用
// window.location.reload(true);代碼
// Response.Write("window.close();}"); // 關閉對話框
// Response.Write("//-->\r\n</script>"); //關閉腳本塊
}
上面的代碼就是關閉對話框和刷新父頁的代碼,這段代碼也可以直接寫入editdata.aspx的html中,然后在后臺cs中調用。
對不起,代碼有點錯。
最后兩行代碼
// Response.Write("window.close();}"); // 關閉對話框
// Response.Write("//-->\r\n</script>"); //關閉腳本塊
不是注釋,應該是
Response.Write("window.close();}"); // 關閉對話框
Response.Write("//-->\r\n</script>"); //關閉腳本塊

文章來源:
http://www.cnblogs.com/fisher1234/archive/2004/11/26/68979.html