#
網頁中嵌入另一個網頁
<IFRAME align=center marginWidth=0 marginHeight=0 src="此處網址" frameBorder=0 width=200 scrolling=no height=100></IFRAME>
關鍵字: iframe,標簽
網頁中經常要嵌套一些iframe,在提交表單的時候,還需要把iframe中的值取出來,和父頁面的form一起提交,很麻煩,好不容易找了個方法,做個筆記:
<iframe src="" name="iframe"/>
<script type="text/javascript">
var tag= document.frames['iframe'].tagname;
</script>
tagname就是iframe頁面中的標簽的名稱,這樣就能獲取到要獲取的值,跟在父頁面一樣處理。
在Iframe中獲取父窗口中表單的值!
<from name="frm" action="bb.asp">
<table>
<tr>
<td><input type="text" name="BH"></td>
</tr>
<tr>
<td><iframe name="ScrollFrame" src="aa.asp" width="100%"></IFRAME></td>
</tr>
</table>
</form>
<script language="javascript">
function show(){
if(document.parentWindow.parent.document.getElementsByName("BH")[0].value=="")
alert("空的");
else
alert("不空");
}
</script>
<input type="button" value="show" onclick="show();">
getElementsByName 是獲取以指定名稱命名的對象數組,
那個頁里只包含一個以"BH"命名的textbox,所以就要加上"[0]"這個了
[0]就表示數組的第一個對象
在上傳文件時出現server is currently unavailable
解決辦法:E:\jboss-3.2.5\server\default\deploy\HSWeb.war\WEB-INF\lib加載commons-fileupload-1.0.jar包
USE pubs
GO
SELECT pub_id, 'Valid (if 1) Text data'
= TEXTVALID ('pub_info.logo', TEXTPTR(logo))
FROM pub_info
ORDER BY pub_id
GO
'Valid (if 1) Text data' 字段返回值是:1 說明image或text,ntext字段里有值.
0:表示為空
出現錯誤:
Activation.main: 出現異常:Port already in use: 1098; nested exception is:
java.net.BindException: Address already in use: JVM_Bind
java.rmi.server.ExportException: Port already in use: 1098; nested exception is:
java.net.BindException: Address already in use: JVM_Bind
at sun.rmi.transport.tcp.TCPTransport.listen(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport.exportObject(Unknown Source)
at sun.rmi.transport.tcp.TCPEndpoint.exportObject(Unknown Source)
at sun.rmi.transport.LiveRef.exportObject(Unknown Source)
at sun.rmi.server.UnicastServerRef.exportObject(Unknown Source)
at sun.rmi.registry.RegistryImpl.setup(Unknown Source)
at sun.rmi.registry.RegistryImpl. <init> (Unknown Source)
at java.rmi.registry.LocateRegistry.createRegistry(Unknown Source)
at sun.rmi.server.Activation.main(Unknown Source)
Caused by: java.net.BindException: Address already in use: JVM_Bind
at java.net.PlainSocketImpl.socketBind(Native Method)
at java.net.PlainSocketImpl.bind(Unknown Source)
at java.net.ServerSocket.bind(Unknown Source)
at java.net.ServerSocket. <init> (Unknown Source)
at java.net.ServerSocket. <init> (Unknown Source)
at sun.rmi.transport.proxy.RMIDirectSocketFactory.createServerSocket(Unknown Source)
at sun.rmi.transport.proxy.RMIMasterSocketFactory.createServerSocket(Unknown Source)
at sun.rmi.transport.tcp.TCPEndpoint.newServerSocket(Unknown Source)
... 9 more
原因及解決辦法:
由于端口在使用的原因,出現這個問題可能是你沒有正常關閉服務器,解決的辦法是在任務管理器中把javaw.exe進程(可能有多個這樣的進程)關掉,重啟服務器就可以了
在做系統數據刪除的時候,往往需要批量刪除一些數據,如何做到呢?下面是一個小例子:
有以下表單:里面有幾個checkbox,如何當點擊第一個checkbox而同時選擇所有的checkbox呢?可以用后面的script方法:
<form>
<table >
<tr>
<td
<input type="checkbox" name="ifAll" id="ifAll" onClick="checkAll()">
</td>
<tr>
<td><input type="checkbox" name="selectFlag" value="checkbox1"></td>
</tr>
<tr>
<td><input type="checkbox" name="selectFlag" value="checkbox1"></td>
</tr>
<tr>
<td><input type="checkbox" name="selectFlag" value="checkbox2"></td>
</tr>
<tr>
<td><input type="checkbox" name="selectFlag" value="checkbox3"></td>
</tr>
<table >
</form>
<script type="text/javascript">
function checkAll() {
for (var i = 0; i < document.getElementsByName("selectFlag").length; i++) {
document.getElementsByName("selectFlag")[i].checked = document.getElementById("ifAll").checked;
}
}
</script>
用以下方法可以得到所有checkbox的值:
String[] userIds = request.getParameterValues("selectFlag");//返回一個數組
然后進行刪除:
調用方法:UserManager.getInstance().deleteUser(userIds);
(具體的方法deleteUser(userIds)如下)
public void deleteUser(String[] userIds) {
StringBuffer sbSql = new StringBuffer();
for (int i =0; i < userIds.length; i++) {
sbSql.append("'")
.append(userIds[i])
.append("',");
}
String sql = "delete from t_user where user_id in (" + sbSql.substring(0, sbSql.length() - 1) + ")";
Connection conn = null;
Statement stmt = null;
try{
conn = DB.getConn();//DB是一個鏈接數據庫的javabeen
stmt = conn.createStatement();
stmt.executeUpdate(sql);
}catch(SQLException e) {
e.printStackTrace();
}finally {
DB.close(stmt);
DB.close(conn);
}
}
javascript 怎樣
控制 <span id=xxx>
文字</span> 中的文字的改變:
<span id="text" onmouseover="this.innerText='數字'">文字</span>
<span id=xxx onclick="this.innerText='hello'">文字</span>
<span id="text" onmouseover="this.firstChild.nodeValue='數字'">文字</span>
innerText是指一個元素里的文本內容
innerHtml是指一個元素里的HTML內容
格式 String.substring(n1,n2) n1為從第幾位開始,n2為截取字符串尾為第幾位
注意:
用substring之前先判斷字符串是否等于null
如果是null再用substring就會拋出NullPointerException的了
如字符串為:lianxidizhi
if(lianxidizhi==""||lianxidizhi==null){
lianxidizhi.substring(0, 6);
}
在deploy發布名稱為一個test.war的應用,
假設端口為80
本地訪問地址為:http://localhost/test
如何在JBOSS設置通過訪問:http://localhost 訪問到test.war應用
create a file named "jboss-web.xml" in the "WEB-INF" directory of the war with content:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE jboss-web PUBLIC "-//JBoss//DTD Web Application 2.3//EN"
"http://www.jboss.org/j2ee/dtd/jboss-web_3_0.dtd">
<jboss-web>
<context-root>/</context-root>
</jboss-web>
在我們敲網頁地址時,我們希望只敲個域名或是其他就可以到達我們想去的地方,那么我們如何設置呢:
找到您將要指向的文件位置如:E:\jboss-4.0.1sp1\server\default\deploy\jbossweb-tomcat50.sar\ROOT.war\index.html
在index.html改為需要指向的路徑如:
<Meta http-equiv="Refresh" Content="0; Url=TT">