一個簡單的javascrip問題,請大家幫忙近來看看,謝謝!
在A頁面點擊按鈕打開B頁面,讓焦點再B頁面上(不關閉B時不能將焦點放到A上);提交B頁面時關閉B頁面,同時刷新A頁面,並讓A頁面獲得焦點.
請問各位老大怎麼用javascrip實現阿!!!
謝謝啦!
------解决方案--------------------看看这个例子,应该是你想要的.
-------test1.htm-------
<script language= "javascript ">
function popUp(toPage,inputid,width,height){ //参数:弹出页面的地址,显示返回结果元素的id,弹出窗口的宽、高
input=document.getElementById(inputid);
v=window.showModalDialog(toPage,this, "dialogWidth: "+width+ "px;status:no;dialogHeight: "+height+ "px ");
if(v!=null)
{
input.value=v;
}
}
</script>
<input type= "text " id= "textfield " /> <input id= "choose " type= "button " value= "选择 " onclick= "popUp( 'test2.htm ', 'textfield ',600,500); "/>
----------test2.htm-------------
<script language= "javascript ">
function choose(value){
window.returnValue=value;
window.close();
}
</script>
<p> <a onclick= "javascript:choose( '选择项一 ') " style= "cursor:hand "> 选择项1 </a> </p>
<p> <a onclick= "javascript:choose( '选择项二 ') " style= "cursor:hand "> 选择项2 </a> </p>
<p> <a onclick= "javascript:choose( '选择项三 ') " style= "cursor:hand "> 选择项3 </a> </p>
<p> <a onclick= "javascript:choose( '选择项四 ') " style= "cursor:hand "> 选择项4 </a> </p>
<p> <a onclick= "javascript:choose( '选择项五 ') " style= "cursor:hand "> 选择项5 </a> </p>
------解决方案--------------------学习!
Window Extensions
Given that the Window object really doesn’t fall completely under any one standard—DOM or JavaScript—and that it is so core to a user’s experience, numerous extensions to the object have been made. Most of these are so new and proprietary that they have yet to be adopted by Web designers at large. This section presents an overview of some of the more useful window extensions made by browser vendors.
IE Window Extensions: Modal, Modeless, and Pop-Up Windows
Internet Explorer supports a few special types of windows. The first is the modal window. Like a standard dialog, this more generic window is modal to the page and must be dismissed before moving on. The basic syntax to create a modal dialog is
window.showModalDialog(URL of dialog, arguments, features);
where
URL of the dialog is a URL to the document to display.
arguments are any objects or values you wish to pass the modal dialog.
features is a semicolon-separated list of display features for the dialog.
A simple example is shown here:
window.showModalDialog( "customdialog.htm ",window, "dialogHeight: 150px;
dialogWidth: 300px; center: yes; help: no; resizable: no; status: no; ");
The showModalDialog() method also returns a value. This value can be set in the dialog document by setting that document’s window.returnValue property. The return of this value will happen automatically. This feature allows for the simple creation of prompt() and confirm() style dialogs, which must return a value.
A modeless window is very different from a modal dialog. A modeless window always stays in front of the window that it was created from, even when that window gains focus. A common use for this might be to display help or other very contextual useful information. However, while different in fun