1. JavaScriptのページを更新する方法
window.location.reload();
window.open()を使用してポップアップウィンドウをポップアップして父ウィンドウを更新します
window.opener.location.reload()
window.showdialogを使用したモードウィンドウポップアップ
window.dialogarguments.location.reload();
2。JavaScriptポップアップウィンドウの2つの実装方法 - 画面の中央ウィンドウにある2つのポップアップ画面の例を以下に示します
window.open()メソッド
次のようにコードコードをコピーします。
関数showdialog(url){
var iwidth = 300;
var iheight = 200;
var itop =(window.screen.height-height)/2;
var ileft =(window.screen.width-iwidth)/2;
window.open(url、 "detail"、 "scrollbars = no、toolbar = no、no、no、local = no、no、resizable = no、no、no、
width = "+iwidth+"、height = "+iheight+"、top = "+itop+"、left = "+les);
}
window.showmodaldialogメソッド
次のようにコードコードをコピーします。
関数showdialog(url){
var iwidth = 300;
var iheight = 200;
var itop =(window.screen.height-height)/2;
var ileft =(window.screen.width-iwidth)/2;
window.showmodaldialog(url、window、 "dialogheight:"+iheight+"px; dialogwidth:"+iwidth+"px;
DialogTop: "+itop+"+ileft+";
}
ここで2番目のパラメーター、ウィンドウに注意してください
3。ページにキャッシュデータを設定する方法
JSPページに次のステートメントを追加します
次のようにコードコードをコピーします。
<%
Response.setheader( "Pragma"、 "no-cache");
Response.setheader( "Cache-Control"、 "no-cache");
Response.setDateHeader( "Expires"、0);
%>
4.ページメソッドを閉じるためのプロンプトはありません
次のようにコードコードをコピーします。
関数closewin(){
var ua = navigator.useragent;
if(ie){{
var ieversion = parsefloat(ua.substring(ua.indexof( "msie")+5、ua.indexof( ";"、ua.indexof( "msie"););););
if(ieversion <5.5){
var str = '';
document.body.insertadjacenthtml( "" beforend "、str);
document.all.notipclose.click();
} それ以外 {
window.opner = null;
}
} それ以外 {
window.close()
}
}
5.ポップアップウィンドウセットをオフにする/タイマーをクリアします
次のようにコードコードをコピーします。
ScriptLanguage = "JavaScript"
! -
functioncloseit(){
setimeout( "self.close()"、100000)//ユニットはミリ秒、ここに100秒があります
setInterval( "self.close()"、100000)
window.cleartimeout(me.timer);
window.clearinterval(me.timer);
/スクリプト
6. JavaScriptがサブウィンドウのサブウィンドウをポップアップします--- URLパス経由
次のようにコードコードをコピーします。
<スクリプト言語= "javascript" type = "text/javascript">
関数fn_modify(pid){
varmedifyInfo = new object();
window.showmodaldialog( "modify_main.asp?pid ="+pid、modiyinfo、 "dialogheight:180px; dialogwidth:300px; dialogleft :; dialogtop:;; resizable:off; center:on; help:off; scoll:off; status off; status oft; : オフ ")
reload();
}
function reload(){location.href = "abc.asp";}
</script>
<a href = "abc.asp" onclight = "fn_modify( 'これは値')"> click </a>
7。JSHidden/Displayフォーム
document.all( "id")
document.all( "id")
document.getElementByID( "BT")display == "none"
document.getElementById( "BT")。
IDはテーブル、入力IDです
8。JS制御フォーム要素は有効/障害です
document.getElementByID( "BT")。
document.all( "submit1")。
document.all( "submit1")
要素の値を設定/取得します
document.getElementByID( "Labtitle")
document.getElementById( "labtitle")
labtitleはdiv、span、テーブルIDです
例1:
コードコードを次のようにコピーします。
<入力型= "button" value = "disabled" onclick = "javascript:document.all.mytext.disabled = 'false'">
<入力型= "button" value = "enable" onclick = "javascript:document.all.mytext.removeattribute( 'disabled')"> ">
例2:
コードコードを次のようにコピーします。
<入力型= "button" value = "disable" onclick = "if(mytext.disabled == false){mytext.disabled = true;。value = 'enable'} else {mytext.disabled; mytext.value = 「使用できます」this.value = 'disable'}>
9.関数を介してページでフォームを送信する方法
次のようにコードコードをコピーします。
関数exit(){){
selcardform.action = "/ndhotel/querytroom.do?method = exitsystem";
selcardform.submit();
}
10。Radioメソッドのトラバース
次のようにコードコードをコピーします。
<入力id = "mode1" type = "radio" name = "workmode" value = "1" checked>
var radios = document.getElementsbyname( "workmode");
var workmode = "";
for(var i = 0; i <radios.length; i ++){
if(radios [i] .checked == true){
workmode = radios [i]。
}
}
11。選択するオプションを動的に追加します
次のようにコードコードをコピーします。
<select id = "ddlprovring" name = "ddlprovince" onchange = "cityresult()">
var prov = document.getElementById( "ddlprovince");
prov.options.add(new option( "---選択---"、 "");
var park = ZoneIdProvince.split( "&");
for(var i = 0; i <parray.length; i ++){
var idparray = parray [i] .split( "#");
var szoneid = idparray [0];
var sprovring = idparray [1];
Prov.Options.Add(新しいオプション(Sprovince、SzoneID));
}
12。ページはプロトタイプAjaxを使用してデータ実装(Java)を送信します
ステップ:<head> </head>に次のJSファイルリンクを追加します
次のようにコードコードをコピーします。
<head>
<スクリプト言語= "javascript" src = "/ndhotel/js/prototype -.6.js"> </script>
</head>
ステップ2:プロトタイプ-.6.jsファイルを/ndhotel/js/指定ディレクトリに入れます
ステップ3:宣言関数を以下に宣言します
次のようにコードコードをコピーします。
<script type = "text/javascript">
関数editipsegment(){
var url = '/ndhotel/ipsegmentset.do?
var pars = 'startip ='+startip+'&endip ='+endip+'&lindex ='+lindex;
new ajax.request(url、{method: 'get'、パラメーター:pars、非同期:false、oncomplete:editresult});
}
関数editResult(result){
var returnstr = result.responsetext;
ifrnstr == 'fail'){
アラート( "");
falseを返します。
}
}
</script>
4つのステップ:バックグラウンドコールを実現します
次のようにコードコードをコピーします。
Public ActionFord RoomChangenotice(ActionMappingマッピング、
actionformフォーム、httpservletrequestリクエスト、
httpservletResponse応答)スロー例外{
文字列結果= "" ;;
printwriter pw = rainprintwriter.getprintwriter(response);
試す {
NotifyServicetwo.sendmessage(4、0);
result = "success";
} catch(例外e){{
logger.error( "roomchangenotice" + e);
}
pw.write(result);
pw.close();
nullを返します。
}
13。JSでフォームの値を取得する方法:
コードコードを次のようにコピーします:document.getElementByID( "lindex")
document.lindex.value // lindexはページの唯一のものでなければなりません
//取得の焦点を設定します
document.getElementById( "lindex")。
document.all.startip.focus()
//失われたフォーカスを設定します
document.getElementById( "lindex")。
document.all.startip.blur()
14.ダイナミックテーブル内のラインを追加/削除します
次のようにコードコードをコピーします。
<表ID = "tdsearch" name = "tdsearch" cellpadding = "0" cellspacing = "0" align = "center">
</table>
//テーブルラインを動的に生成します
var autoid = 0;
関数addrow(value1、value2){{
var highquery = document.getElementById( "tdsearch");
highquery.insertrow();
var newrow = highquery.rows [highquery.rows.length -1];
newRow.id = "row_" + autoid;
newRow.InsertCell();
newRow.Cells [0] .innerhtml = "<input width = '200' value = '"+value1+"' onchange = 'changeip("+autoid+")' type = 'text' id = 'bipffffffffff rom _"+autoid+ "'> - ";
newRow.InsertCell();
newRow.Cells [1] .innerhtml = "<input width = '200' value = '"+value2+"' type = 'text' id = 'bipto _"+autoid+"'" "" "" "" ""
var cell2 = newRow.InsertCell();
cell2.innerhtml = "<input class = 'btn_1word' type = 'button' class = 'hq_button' value = 'onclick = removerow('" + newrow.id + "')>" ;;
cell2.setattribute( "class"、 "yellowcell2");
autoid = autoid+1;
}
関数removerow(rowid){
var trow = document.getElementbyid(rowid);
// alert(trow);
// if(rowid!= "row_0"){
trow.removenode(true);
//}
}
15。コレクション
次のようにコードコードをコピーします。
//はじめに進行状況バーを表示します
document.all( "btnimport")。
document.all( "datagrid_waitdiv")。
document.all( "datagrid_waitdiv")。
document.all( "datagrid_waitdiv")。
form1.action = "//ndhotel/jsp/systemset/roomset/uploadfile.jsp";
form1.submit();
16.新しいウィンドウを作成します
function layer1addgroup(){
var url = '/ndhotel/jsp/systemset/roomset/addgroup.jsp';
var newwin = window.showmodaldialog(url、window、 "dialogwidth = 470px; dialogheight = 400px; scroll = yes; hardus = no;");
}
//父ページを更新します
関数roommainleftrightframe(){){)
var layer = '<%= layer%>';
window.parent.parent.frames( 'view')。
}
17.テキストボックスを設定して属性のみを読み取る/テキストボックスの色を設定する/ラジオ選択を設定する
次のようにコードコードをコピーします。
document.all( "txt_autotime")。
document.all( "txt_autotime")。
runparamsetform.radnotforcibly.checked = true;
// IPアドレス検証
function ipcheck(ipvalue){{
var reg =/^/d {1,3}(/./d {1,3}){3} $;
if(ipvalue!= ""){{
if(reg.test(ipvalue)){
var ary = ipvalue.split( '。');
for(aryのキー){
if(parseint(ary [key])> 255
falseを返します。
}
trueを返します。
} それ以外
falseを返します。
} それ以外
trueを返します。
}