ITeye博客

javascript

共 85 篇文章

文字向上滚动特效,在一行中切换,可以用在新闻或者公告中

<!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> <style type="text/css"> <!-- body {…

2009-07-07 09:24 · javascript

焦点图片轮换2

<!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=utf-8" /> <title>焦点图片第三季</title> <style type="text/css"> /* Reset …

2009-07-05 09:46 · javascript

用javascript 控制跳转页面

当面跳转的核心代码是:"location.href=value" 新页面打开的核心代码是:"window.open()" 而还需注意的就是javasrcipt代码的嵌入位置:(1)直接跳转或打开的javascript 代码是嵌入在<select>中的,(2)提交后跳转或新页面打开是嵌入到提交按钮中的,并且按钮不是用"submit",而是用"button",调用javascript 是用"onclick",而没有在<form>中用"onsubmit" 下面分别是四种情况的代码: a1(当页,直接跳转): <select name="qq" onchange="javascript:locati…

2009-07-04 10:52 · javascript

可刷新的JS树形菜单特效

<!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>Div+CSS+JS树型菜单,可刷新</title> <meta name="description…

2009-06-27 08:59 · javascript

如何让人家复制自己网站信息自动加上网址,复制页面加上网址特效

///复制网站内容自动加上网址 document.body.oncopy = function () { setTimeout( function () { var text = clipboardData.getData("text"); if (text) { text = text + "\r\n 详细出处参考:"+location.href; clipboardData.setData("text", text); } }, 100 ) }

2009-06-24 06:28 · javascript

JS仿flash动态切换(横向,带分页器控制,自动正反向循环轮播)

<!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=utf-8" /> <title></title> <link rel="stylesheet" href="http://www.…

2009-06-24 06:06 · javascript

js操作select下拉列表的一些通用代码

设置select中value="paraValue"的Item为选中 //document.all.objSelect.value = objItemValue; //得到select的当前选中项的value //var currSelectValue = document.all.objSelect.value; //得到select的当前选中项的text //var currSelectText = document.all.objSelect.options[document.all.objSelect.selectedIndex].text; //得到select的当前选中项的Ind…

2009-06-22 09:32 · javascript

js设置select列表中特定项为选中状态

设置select中text="paraText"的第一个Item为选中 function jsSelectItemByValue(objSelect,objItemText) { //判断是否存在 var isExit = false; for(var i=0;i<objSelect.options.length;i++) { if(objSelect.options[i].text == objItemText) { objSelect.options[i].selected = true; isExit = true; break; } } //Show出结果 if(isExit) { …

2009-06-22 09:28 · javascript

js修改select列表选项中的值

4.修改select选项中 value="paraValue"的text为"paraText" function jsUpdateItemToSelect(objSelect,objItemText,objItemValue) { //判断是否存在 if(jsSelectIsExitItem(objSelect,objItemValue)) { for(var i=0;i<objSelect.options.length;i++) { if(objSelect.options[i].value == objItemValue) { objSelect.options[i].text = ob…

2009-06-21 21:57 · javascript

js从select列表选项中删除一个Item项

//3.从select选项中 删除一个Item function jsRemoveItemFromSelect(objSelect,objItemValue) { //判断是否存在 if(jsSelectIsExitItem(objSelect,objItemValue)) { for(var i=0;i<objSelect.options.length;i++) { if(objSelect.options[i].value == objItemValue) { objSelect.options.remove(i); break; } } alert("成功删除"); } else { …

2009-06-20 08:12 · javascript

js如何向select选项中插入新值

通过以下的函数,你可以轻松实现向select插入新的item值 //2.向select选项中 加入一个Item function jsAddItemToSelect(objSelect,objItemText,objItemValue) { //判断是否存在 if(jsSelectIsExitItem(objSelect,objItemValue)) { alert("该Item的Value值已经存在"); } else { var varItem = new Option(objItemText,objItemValue); // objSelect.options[objSelect.o…

2009-06-20 08:10 · javascript

js判断select列表值的函数

//1.判断select选项中 是否存在Value="paraValue"的Item function jsSelectIsExitItem(objSelect,objItemValue) { var isExit = false; for(var i=0;i<objSelect.options.length;i++) { if(objSelect.options[i].value == objItemValue) { isExit = true; break; } } return isExit; } http://www.corange.cn/archives/2008/10/2113.…

2009-06-19 09:29 · javascript

escape解决AJAX中文乱码的简单方法

在使用AJAX开发网站时,经常有朋友遇到乱码的问题,而且一下子难以找到解决方法。其实解决AJAX中文乱码问题很简单。 1、服务端程序: 以下为引用的内容: <!-- liststr="AJAX中文乱码的简单解决方法" sponse.write escape(liststr) '用escape编码 --> 2、客户端JAVASCRIPT程序 function toserver(url) { var req = new XMLHttpRequest(); if (req) { req.onreadystatechange = function() { if (req.readyState == …

2009-06-09 11:29 · javascript

静态页面下用javascript操作ACCESS数据库(读增改删)的代码

<script language="javascript"> //用 JavaScript 写服务器端连接数据库的代码示例 var conn = new ActiveXObject("ADODB.Connection"); conn.Open("DBQ=E:\\a.mdb;DRIVER={Microsoft Access Driver (*.mdb)};"); var rs = new ActiveXObject("ADODB.Recordset"); var sql="select * from friends_infor"; rs.open(sql, conn); shtml = "<t…

2009-05-29 12:36 · javascript

如何让一个层关闭之后,就算刷新页面了也不显示。除非关闭页面再次打开

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>一个层关闭之后,就算刷新页面了也不显示。除非关闭页面再次打开</title> <style type="text/css"> #myDiv{ border:1px solid red; background:#cccccc; wid…

2009-05-21 21:31 · javascript

通过xajax给fckeditor增加自动保存草稿功能

使用的xajax版本是0.5.4beta,fckeditor版本是2.4.3,通过xajax给fckeditor增加自动保存草稿功能, 本文侧重于演示,使用sessionid记录对应关系,用户关闭浏览器後数据就会消失,在实际应用中可以使用数据库存储数据,修改保存函数autosave和调用函数loadcache 即可. <?php session_start(); define('ROOT_DIR',str_replace("\","/",dirname(__FILE__))); $cachedir = './cache/'; //清除超过1天的记录文件 function clearcache…

2009-05-20 10:09 · javascript

xajax如何获取fckeditor的值

xajax向html页面输出fckeditor是容易的,但是xajax如何获取fckeditor的值?在xajax的wiki上说了,但还是不明白,测试不成功,最后在fckeditor 2.4.3的_samples/html/sample08.html中找到了答案 function GetContents() { // Get the editor instance that we want to interact with. var oEditor = FCKeditorAPI.GetInstance('content1') ; // Get the editor contents in X…

2009-05-19 08:22 · javascript

xajax无刷新上传实例

http://www.corange.cn/archives/2008/10/2080.html 主要的xajax结合php上传文件和保存数据的函数集中存放在 ./admin/includes/function.xajax.php 里面 在language.php文件载入并初始化xajax上传扩展 require_once(ROOT_PATH . '/includes/xajax/xajax.inc.php'); require_once(ROOT_PATH . '/admin/includes/function.xajax.php'); require_once(ROOT_PATH . '…

2009-05-17 10:03 · javascript

ajax拖动层,保存层位置,这段代码是从网络人扒拉下来的(非XAJAX),使用类库prototype.js,感觉效果非常好

下载地址 http://www.corange.cn//uploadfiles/ajax[1].select_22983.rar <script>window.onload = function(){getPage("http://localhost/xuexi/tuodong/xajaxcontent.htm?"+new Date().getTime(),"content");}</script> 注意文件路径,你下载演示时候可以看到

2009-05-16 00:13 · javascript

用 Javascript 验证表单(form)中的单选(radio)值

在用 Javascript 验证表单(form)中的单选框(radio)是否选中时,很多新手都会遇到问题,原因是 radio 和普通的文本框在获取值的时候有很大不同,本文介绍了一个较为通用的获取 radio 值的方法,希望对新手有用。 -------------------------------------------------------------- 点此浏览示例文件 -------------------------------------------------------------- Javascript: <script type="text/javascript"> //…

2009-05-13 08:34 · javascript