分类: Ajax/Js预览模式: 普通 | 列表
09-07
08

JavaScript 中的replace方法,正则或字符串全部交替

第一次发现javascript中replace() 方法如果直接用str.replace("-","!") 只会替换第一个匹配的字符.

引用内容 引用内容
replace()
The replace() method returns the string that results when you replace text matching its first argument
    (a regular e­xpression) with the text of the second argument (a string).
    If the g (global) flag is not set in the regular e­xpression declaration, this method replaces only the first
    occurrence of the pattern. For example,

var s = "Hello. Regexps are fun.";s = s.replace(/\./, "!"); // replace first period with an exclamation pointalert(s);

查看更多...

Tags: JS replace all 正则

分类:Ajax/Js | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 322
09-07
03

火狐IE兼容问题大全

一直用ie为准做网页,今天到火狐官方网站下了个没有google插件的安装了(特别讨厌插件,而国内几乎下载不到没有google插件的火狐浏览器!)

打开一看,哇哈,终于来了,ff好多不兼容的问题来了。随便点击了下不兼容的问题就有上十个了。一个个慢慢解决,慢慢搜索。。。。。。。先把几个简单的整理分享一下。

1.最简单的鼠标移过手变型的css要改了 cursor:pointer;/*ff不支持cursor:hand*/ dw8下面自动出来的也没有hand这个属性了,标准的是pointer

2.ff不支持滤镜 最常见的半透明不支持。

filter: Alpha(Opacity=50); /* for IE */

查看更多...

Tags: 兼容 火狐 firefox

分类:Ajax/Js | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 333
<script>
try{
alert("经 encodeURI()得到的值是:"+encodeURI('wd=经')+"\n而非wd=%BE%AD")
}catch(e){
alert("错了吧!");
}
try{
alert(decodeURI("%BE%AD"))
}catch(e){

查看更多...

Tags: encodeURI url 汉字

分类:Ajax/Js | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 613
09-02
17

js为空或不是对象的解决方法

1. 'null'为空或不是对象:

<script type="text/javascript"> 里面加个defer=true属性试试看,

即:<script type="text/javascript" defer=true>

2. document.getElementById为null

原因: var titab=document.getElementById("titletab");没有取到对象

查看更多...

Tags:

分类:Ajax/Js | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 662
09-02
13

左右悬浮广告代码

2007-09-28 16:47var delta=0.15

var collection;

function floaters() {

   this.items = [];

   this.addItem = function(id,x,y,content)

查看更多...

Tags: 广告 悬浮

分类:Ajax/Js | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 394
09-02
10

一个cookie控制的弹窗

<script>
function openpopup(){
window.open("http://www.xxx.com/","","width=300,height=300,scroolbars=no") //自己修改弹出窗口  
}  
function get_cookie(Name) {
var search = Name + "="
var returnvalue = "";
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(search)

查看更多...

Tags: Cookie

分类:Ajax/Js | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 355