共 82篇 前 10 页: 10    每页5篇 下一页  

javascript学习

              

<%@ page contentType="text/html;charset=GB2312" %>
<%@ include file=
"javabean/useBean.jsp"%>

<!--控制二次提交的js start-->
<script language=
"JavaScript" type="text/javascript">

function submitQuest(frm){
var allselected=0;
var needSelectCount=1

if (frm.refer_flag.value==
"Y"){
alert(
"您已经提交过一次答案!请重新开始一组题!");
return false;
}else{
frm.timeout_flag.value=1;
if(frm.refer_flag.value!=
"Y"){
if(frm.remain_time.value<=0){
frm.timeout_flag.value=0;
}else{
frm.timeout_flag.value=1;
}
frm.refer_flag.value=
"Y";
frm.submit();
return true;
}
}
}
</script>
<!--控制二次提交的js end-->
<%
  
String classId=request.getParameter(
"classId");

%>

<form name=
"actionfrm" id="actionfrm" method="post" action="doquest.jsp">
<p>
  <input type=
"hidden" name="timeout_flag">
  <input type=
"hidden" name="refer_flag" >
  <script language=
"JavaScript" type="text/javascript">
function reflash_page(){
if (document.actionfrm.refer_flag.value==
"Y")
window.location.href = window.location.href;
}
reflash_page();
</script>

<!--控制时间的(到计时)开始-->
  <input type=
"text" name="remain_time" readonly size="3" value="120" style="color:#AC1605;height:18px;border:0px;font-size:14px">
    秒</p>
<p>
<script language=
"JavaScript" type="text/javascript">
function time_step(){
var frm = document.actionfrm;
var r = frm.remain_time;
if(r.value<=1){
r.value=0;
alert(
"用户您好!规定完成答题的时间已到!系统将自动提交您的答案。");
submitQuest(frm);
}
if (frm.refer_flag.value!=
"Y")
r.value=(r.value!=0)?r.value-1:0;

window.setTimeout(
"time_step()",1000);
}
time_step();
</script>
<!--控制时间的(到计时)结束-->
    
<img src=
"img/dti2.jpg" width="115" height="28" onClick="submitQuest(document.actionfrm);"/></p>


      
lunzi   2006-08-03 23:36:01 阅读:1950  评论:2  引用:0
前端文件

<!DOCTYPE html>
<html>
<head>
    <meta charset=
"utf-8" />
        <title>消息提醒</title>
</head>
<body>

<div id=
"hd">

<ul class=
"panel">
   收件箱<span data-type=
"msg">0</span>
</ul>
<ul class=
"panel3">
   收件箱<span data-type=
"msg">0</span>
</ul>
</div>


<script type=
"text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
<script type=
"text/javascript">
<!--
//收件箱
checkbox = function(url) {
var box = $('#hd .panel');
$.getJSON(url, function(data) {
for (k in data[0]) {
if (k == 'msg') {
if (data[0][k] > 0)
box.find('[data-type=' + k + ']').show().text(data[0][k]);
else
box.find('[data-type=' + k + ']').hide();
}
}
});
setTimeout(function() {
sbs.checkbox(url)
}, 10000);
}

checkbox3 = function(url) {
var box = $('#hd .panel3');
$.getJSON(url, function(data) {
alert(data[0]['msg']);
for (k in data[0]) {
if (k == 'msg') {
if (data[0][k] > 0)
box.find('[data-type=' + k + ']').show().text(data[0][k]);
else
box.find('[data-type=' + k + ']').hide();
}
}
});
}

checkbox('server/msg_count.php');
checkbox3('server/msg_count.php');
//-->
</script>



server/msg_count.php

<?php

$msgn = array (array (
"msg" => 10) );
echo json_encode ( $msgn );


lunzi   2013-07-28 13:25:54 阅读:783  评论:0  引用:0
在程序中显示一下Ext.BLANK_IMAGE_URL变量,竟然是http://extjs.com/s.gif,不过这就好办了,只需要在程序开始处将Ext.BLANK_IMAGE_URL变量的值改成自己机器上的路径即可。如下面的代码所示:

  Ext.BLANK_IMAGE_URL="../script/resources/images/default/s.gif"


本文来自:站才网(www.zhancai.com)  原文链接:http://www.zhancai.com/edu_zhizuo_dhtml/32969.html
lunzi   2012-02-05 18:02:51 阅读:666  评论:1  引用:0
查看
lunzi   2011-03-27 22:24:56 阅读:1686  评论:5  引用:0
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Raker</title>
<style type="text/css">
<!--
.STYLE1 { color: #009999 }
body { background:#000; color:#fff; font-size:2em }
dl dt { width:480px; text-align:center; padding-top:150px }
dl dd { width:480px; text-align:center; margin:0; padding-top:40px }
img { border:0 }
-->
</style>
<script type="text/javascript">
function request(paras) //用来得到url地址里面的参数
{
var url = location.href;
var paraString = url.substring(url.indexOf("?")+1,url.length).split("&");
var paraObj = {}
for (i=0; j=paraString; i++){
paraObj[j.substring(0,j.indexOf("=")).toLowerCase()] = j.substring(j.indexOf("=")+1,j.length);
}
var returnValue = paraObj[paras.toLowerCase()];
if(typeof(returnValue)=="undefined"){
return "";
}else{
return returnValue;
}
}

//alert(request('view'));
</script>
</head>
<body>
<dl>
  <dt>Connection exception</dt>
  <dd><img src="img/01.png" /></dd>
  <dd><a href="#"><img id="clewImg" src="img/but_01.png" /></a>
  <script type="text/javascript">
   document.getElementById('clewImg').src = "img/but_0"+request('view')+".png";
  </script>
    <!--<a href="#"><img src="img/but_02.png" /></a>-->
  </dd>
</dl>
</body>
</html>
lunzi   2011-03-26 16:23:18 阅读:2968  评论:1  引用:0






<a id="pro_img_url" href="http://www.zhuoda.org/lunzi/"><img src="http://data.rakoo.cn/image/AndroidGameImg/game/logo/1000007.png" id="pro_img"></a>

  <!--文字特效开始-->
<script type="text/javascript">
    var n = 0;
    function changeColorIndex_agri(){
        n++;
        switch(n){
           case 1:return "http://data.rakoo.cn/image/AndroidGameImg/game/logo/1000001.jpg";
           case 2:return  "http://data.rakoo.cn/image/AndroidGameImg/game/logo/1000004.jpg";
           case 3:return  "http://data.rakoo.cn/image/AndroidGameImg/game/logo/5420.jpg";
           default:return "http://data.rakoo.cn/image/AndroidGameImg/game/logo/1000007.png";
        }
    }
    function colorfullIndex_agri() {
         var tt =document.getElementById('pro_img')
var url =document.getElementById('pro_img_url')
        // tt.style.color=changeColorIndex_agri();
pro_img.src = changeColorIndex_agri();
if (n == 0 || n==2){
url.href = "http://www.zhuoda.org/lunzi/";
} else if(n == 1) {
url.href = "http://www.zhuoda.org/lunzi2/";
}
        
//alert(pro_img.src);

         if(n==2)n=0;
        setTimeout('colorfullIndex_agri()',2000);
    }
    colorfullIndex_agri();

</script>
<!--文字特效结束-->
lunzi   2011-01-28 17:43:49 阅读:5133  评论:0  引用:0
<div id="changeOptions">
<a>
    <span style="cursor:pointer"  onclick="left();"><<</span>
    </a>
    
    <a href="#"></a>
    <span id="first" onclick="chooseMode('first')">容易</span>
    
    <a href="#"></a>
    <span id="second" onclick="chooseMode('second')">一般</span>
    
    
    <a>
    <span style="cursor:pointer" onclick="right();">>></span>
    </a>

</div>



<script>
     var arrayList = new Array();
var index ;
var left_index;
var arrLength ;

function chooseMode(v){
if ('first'==v) {
alert(document.getElementById('first').innerHTML);
document.getElementById('mode').value= getMode(document.getElementById('first').innerHTML);
} else if('second'==v){
alert(document.getElementById('second').innerHTML);
document.getElementById('mode').value= getMode(document.getElementById('second').innerHTML);
}
}



function initModes()
{
index = 0;
left_index = index;

arrayList[0]= [1,'容易'];

arrayList[1]= [2,'一般'];

arrayList[2]= [3,'困难'];

arrayList[3]= [4,'特难'];

arrLength= arrayList.length;
document.getElementById("first").innerHTML = arrayList[0][1];
document.getElementById("second").innerHTML = arrayList[1][1];
//alert(document.getElementById("first").innerHTML);
}

function getMode(modeName){ //alert(modeName);
for (var i=0;i<arrLength; i++) {
if (modeName == arrayList[1]){
//alert(arrayList[0]+'-'+arrayList[1]);
return arrayList[0];
}
}
}

function right()
{
if(left_index<0){
index = arrLength + left_index;
left_index = 0;
}

index = index + 1;
if(index>(arrLength-1)){
index = 0;
}

if(index == arrLength-1)
{
document.getElementById("first").innerHTML = arrayList[index][1];
document.getElementById("second").innerHTML = arrayList[0][1];
}
else{
document.getElementById("first").innerHTML = arrayList[index][1];
document.getElementById("second").innerHTML = arrayList[index+1][1];
}
//alert('index='+index+'|left_index='+left_index);
}

function left()
{
    
    if (index > 0){
     left_index = index-arrLength;
     index = 0;
    }
    
    left_index = left_index - 1;
    if (left_index<=(-arrLength)) {
     left_index = 0;
     document.getElementById("first").innerHTML = arrayList[0][1];
document.getElementById("second").innerHTML = arrayList[1][1];
    } else {
     document.getElementById("first").innerHTML = arrayList[arrLength+left_index][1];
document.getElementById("second").innerHTML = arrayList[(arrLength+left_index)==(arrLength-1)?0:(arrLength+left_index+1)][1];
    }
    //alert('left='+left_index+'|index='+index);


}

initModes();
    </script>



lunzi   2010-11-17 22:25:52 阅读:2535  评论:1  引用:0
效果图如下:

前端实现代码如下:

hello2.jsp
<%@ page language=
"java" pageEncoding="UTF-8"%>
<%@ include file=
"/common/getContextPath.jsp"%>
<script type=
"text/javascript" src="js/prototype.js"></script>
<script type=
"text/javascript" src="js/ajax.js"></script>

<style type=
"text/css">
.list {
float:left;
width:100%;
}
</style>

<body>
<input type=
"text" id="itext" size="50" /><input type="submit" value="搜索"/>
<div id=
"outdiv"
style=
"display: none; width: 200px; height: auto; position: absolute; left: 16px; top: 41px;">
111
</div>
</body>

<script type=
"text/javascript">
var request = getHTTPObject();

//firefox下检测状态改变只能用oninput,且需要用addEventListener来注册事件。
if(/msie/i.test(navigator.userAgent))    
//ie浏览器
{
document.getElementById('itext').onpropertychange=dealFun
}
else
{
//非ie浏览器,比如Firefox
document.getElementById('itext').addEventListener(
"input",dealFun,false);
}
  
//键盘抬起时激活的函数
document.onkeyup  =  dealFun;


function  dealFun(e){
    e   =   window.event   ||   e;
    
    if(e){
    if(e.keyCode==38){
        return;
    }else if(e.keyCode==40){
     return;
    }
  
// alert(e.keyCode);
    }
    
    var inputvalue=$(
"itext").value;
    if(inputvalue ==''||inputvalue==null){
     Element.hide(
"outdiv");
     return;
    }
    var url=
"${basePath}/search/searchSuggest.action?keyword="+encodeURIComponent(inputvalue);
    
//获取用户当前输入的内容
    
request.open(
"GET", url, true);
    request.onreadystatechange = show;
    
    request.send(null);
}


function show(){
   if (request.readyState == 4) {
      if (request.status == 200) {
        Element.show(
"outdiv");
        var response = request.responseText;
        var json =eval('('+response+')')
//这句最重要,上面可以忽略
        
        var temp =
"";
    var outdiv = $(
"outdiv");
    for(var i = 0;i < json['data'].length;i++){
        temp = temp +
"<div class='list' style='background-color: #ECEDFF;'  onMouseOver=this.style.backgroundColor='#dddddd' onMouseOut=this.style.backgroundColor='#ECEDFF'   onclick='inMessage(this)'>" +json['data']<i>['word']+ "</div>" +"<br>";
    }
    outdiv.innerHTML = temp;

      }
    }
}

function inMessage(obj){
    $(itext).value = obj.innerHTML;
    Element.hide(
"outdiv");
}

function selectMessage(obj){
    $(itext).value = obj.innerHTML;
}


var   currentLine   =   -1;
document.onkeydown   =   function   (e)    
{
    e   =   window.event   ||   e;
    switch   (e.keyCode)    
    {
        case   38:
            currentLine--;
            changeItem();
            break;
        case   40:
            currentLine++;
            changeItem();
            break;
        default   :
            break;
    }
}

//改变选择项目
function   changeItem()
{
    this.$$ = function(o, str){ return o.getElementsByTagName(str);}
    var   it   =   document.getElementById(
"outdiv");
    var divs = this.$$(it, 'div');
    var len = divs.length;
    for   (i=0;i<len;i++)    
    {
        divs<i>.style.backgroundColor =
"#ECEDFF";
    }
    if   (currentLine   <   0)
        currentLine   =   len   -   1;
    if   (currentLine   ==   len)
        currentLine   =   0;
        
   if(currentLine>0){
     divs[currentLine].style.backgroundColor =
"#dddddd";
     selectMessage(divs[currentLine]);
   }
  
}

</script>


ajax.js

function getHTTPObject() {
var request = false;
try {
request = new XMLHttpRequest();
}
catch (trymicrosoft) {
try {
request = new ActiveXObject(
"Msxml2.XMLHTTP");
}
catch (othermicrosoft) {
try {
request = new ActiveXObject(
"Microsoft.XMLHTTP");
}
catch (failed) {
request = false;
}
}
}
return request;
}


lunzi   2010-10-11 17:42:34 阅读:1317  评论:0  引用:0
<style type="text/css">
.dropDiv {
position: absolute;
z-index: 10;
display: none;
cursor: hand;
background-color: #eee;
}
.dropDiv .jhover {
background-color: #CCCCCC;
}
.dropDiv .list {
float:left;
width:100%;
}
.dropDiv .word {
float:left;
}
.dropDiv .view {
float:right;
color: gray;
text-align: right;
font-size: 10pt;
}
</style>

<script>
   function over(obj){
      obj.className = "list jhover";
   }
   function down(obj){
      obj.className = "list";
   }
  
  
</script>

<script   language="javascript">
<!--
var   currentLine   =   -1;
document.onkeydown   =   function   (e)    
{
    e   =   window.event   ||   e;
    switch   (e.keyCode)    
    {
        case   38:
            currentLine--;
            changeItem();
            break;
        case   40:
            currentLine++;
            changeItem();
            break;
        default   :
            break;
    }
}
  
//改变选择项目
function   changeItem()
{
    this.$$ = function(o, str){ return o.getElementsByTagName(str);}
    var   it   =   document.getElementById("ice");
var divs = this.$$(it, 'div');
var len = divs.length;
    for   (i=0;i<len;i++)    
    {
        divs.className   =   "list";
    }
    if   (currentLine   <   0)
        currentLine   =   len   -   1;
    if   (currentLine   ==   len)
        currentLine   =   0;
    divs[currentLine].className   =   "list jhover";
}
  
//-->
</script>


<div id="ice" class="dropDiv" style="border: 1px solid rgb(1, 69, 149); left: 911.5px; top: 39px; width: 193px; display: block;">
<div class="list " onMouseOver="over(this);" onMouseOut="down(this)" ><div class="word">一只苍蝇的激情四射</div></div>
<div class="list " onMouseOver="over(this);" onMouseOut="down(this)" ><div class="word">一只苍蝇的激情四射</div></div>
<div class="list " onMouseOver="over(this);" onMouseOut="down(this)" ><div class="word">一只苍蝇的激情四射</div></div>
<div class="list " onMouseOver="over(this);" onMouseOut="down(this)" ><div class="word">一只苍蝇的激情四射</div></div>
<div class="list " onMouseOver="over(this);" onMouseOut="down(this)" ><div class="word">一只苍蝇的激情四射</div></div>
<div class="list " onMouseOver="over(this);" onMouseOut="down(this)" ><div class="word">一只苍蝇的激情四射</div></div>
<div class="list " onMouseOver="over(this);" onMouseOut="down(this)" ><div class="word">一只苍蝇的激情四射</div></div>
<div class="list " onMouseOver="over(this);" onMouseOut="down(this)" ><div class="word">一只苍蝇的激情四射</div></div>
<div class="list " onMouseOver="over(this);" onMouseOut="down(this)" ><div class="word">一只苍蝇的激情四射</div></div>
</div>

<script>
    

//alert(xdd);
</script>
lunzi   2010-10-10 20:36:19 阅读:1320  评论:1  引用:0
<!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="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>

<body>
<input id="test2" value="test2"/>
<script>
function attClick()//handler of click event
{
alert('hello');
}

function attClick2()//handler of click event
{
alert('hello2');
}

var test2 = document.getElementById('test2');

if(test2.addEventListener){
  test2.addEventListener("click",attClick,false);
  test2.addEventListener("click",attClick2,false);
}else{
  test2.attachEvent("onclick",attClick,false);
  test2.attachEvent("onclick",attClick2,false);
}


function checkNum(e){
   if(e.value=="")return;
   /^([0-9]*)/.exec(e.value);
  
   if(e.value!=RegExp.$1)e.value = RegExp.$1;
}
</script>

<input type="text" name="x" onkeyup="checkNum(this)"/>




<div id="ice" class="dropDiv" style="border: 1px solid rgb(1, 69, 149); left: 911.5px; top: 39px; width: 193px; display: block;">
<div class="list " onMouseOver="this.style.backgroundColor='#ffffff'" onMouseOut="this.style.backgroundColor='#dddddd'" ><div class="word">一只苍蝇的激情四射</div></div>
<div class="list " onMouseOver="this.style.backgroundColor='#ffffff'" onMouseOut="this.style.backgroundColor='#dddddd'" ><div class="word">一只苍蝇的激情四射</div></div>
<div class="list " onMouseOver="this.style.backgroundColor='#ffffff'" onMouseOut="this.style.backgroundColor='#dddddd'" ><div class="word">一只苍蝇的激情四射</div></div>
<div class="list " onMouseOver="this.style.backgroundColor='#ffffff'" onMouseOut="this.style.backgroundColor='#dddddd'" ><div class="word">一只苍蝇的激情四射</div></div>
<div class="list " onMouseOver="this.style.backgroundColor='#ffffff'" onMouseOut="this.style.backgroundColor='#dddddd'" ><div class="word">一只苍蝇的激情四射</div></div>
<div class="list " onMouseOver="this.style.backgroundColor='#ffffff'" onMouseOut="this.style.backgroundColor='#dddddd'" ><div class="word">一只苍蝇的激情四射</div></div>
<div class="list " onMouseOver="this.style.backgroundColor='#ffffff'" onMouseOut="this.style.backgroundColor='#dddddd'" ><div class="word">一只苍蝇的激情四射</div></div>
<div class="list " onMouseOver="this.style.backgroundColor='#ffffff'" onMouseOut="this.style.backgroundColor='#dddddd'" ><div class="word">一只苍蝇的激情四射</div></div>
<div class="list " onMouseOver="this.style.backgroundColor='#ffffff'" onMouseOut="this.style.backgroundColor='#dddddd'" ><div class="word">一只苍蝇的激情四射</div></div>
</div>


//元字符
<script>
   var strXml = "<author>jack</author>";
   var regExp = /<author>(\w*)<\/author>/;
   regExp.exec(strXml);
   var author = RegExp.$1;
   //alert(author);
  
   function stripTags(s){
   return s.replace(/<\/?[^>]+>/gi,'');
   }
  
   var str = stripTags("<author>jack</author>");
   //alert(str);
  
   function hello(){
   alert("hello");
   }
   window.setTimeout(hello,1000);
   /*document.onclick = function(){
   window.clearTimeout(id);
   }*/
</script>





</body>
</html>
lunzi   2010-10-10 16:30:06 阅读:638  评论:0  引用:0
Copyright@2004-2010 powered by YuLog