js调试函数
参考php的debug函数修改了一下JS版的。 firebug 下使用控制台 ie使用 alert弹出
/**
* 内部调试
**/
function debug(v){
if(window.console && window.console.log){
window.console.log(v);
}else{
alert(v);
}
}
通过script标签增加JS
工作需要在前端的代码通过xxx.js?m=m&x=x 的方法来通过js加载JS文件。
JS:
//MS闭包,不让代码互相影响,我也用的不多
(function(){
var simcn = {
src:[],
init:function(){
var __g = document.getElementById('simcnworkframe');
this.srcUrl(__g.src);
},
run:function(){
this.init();
var head = document.getElementsByTagName('head')[0];
var j=0;
for(i in this.src){
var t = document.createElement('script');
t.src = this.src[i] + '.js' ;
t.id = "simc_" + this.src[i];
head.appendChild(t);
}
},
srcUrl:function(_u){
var jl = _u.split('.js?')[1].split('&');
for(i in jl){
this.src.push(jl[i].split('=')[1]);
}
}
};
simcn.run();
})()
//m.js
alert('m.js')
//c.js
alert('c.js')
//v.js
alert('v.js')
【全球号召】拯救MySQL!
作为MySQL的多年忠实用户,并且个人也非常喜欢MySQL,看到了MySQL创始人发出的号召,毫不犹豫的
参加了签名活动,希望大家也能参加!(希望大家转发此文,共同参与)
马上参加“拯救MySQL”签名活动!
MySQL 创始人请求帮助邮件:http://www.cnbeta.com/articles/102517.htm
国内媒体报道:http://tech.sina.com.cn/it/2010-01-04/21153736195.shtml
改变系统hosts的软件(PYTHON写的)
做前端,测试,程序开发需要不停的转换系统hosts文件。
用批处理与EDIT在集成测试时比较麻烦,所以写下这个软件
FOR XP
改变系统hosts工具-XP
FOR WIN7
改变系统hosts工具-windows7
其他平台没有试过。
使用 python2.5 + wxpython2.8 + py2exe
功能比较简单。
回车关闭弹出层
//按回车关闭按钮事件
//需要在页面的body加个事件
function key_layer_close_v31(e){
var isie = (document.all) ? true : false;
var key = isie ? window.event.keyCode : e.which ;
if(key==13){
if(document.getElementById('phishing').style.display=='block' && document.getElementById('read_complete').disabled == false ){
UED.layer31.close();
}
}
return false;
}
清除IE6在HTTPS安全提示问题
1. 检查所有的iframe中是否有为空的或者引用其他地方(如果有为空的,需要设计为 JAVASCRIPT:FALSE)
2. 不能引用外部的HTTP相关内容(可以使用HTTPS引用,图片样式与脚本)
python改变系统hosts
因工作需要一直修改系统hosts,以切换内网,外网,其他测试服务器。
天天改比较麻烦写了这个小工具比较简单, 打包成EXE后比较大(不过自己用的东西就没啥讲究了)
贴上源代码
#-* coding:GBK *-
import os
import wx
def create(parent):
return Frame1(parent)
# assign ID numbers
[wxID_FRAME1, wxID_FRAME1BUTTON1, wxID_FRAME1BUTTON2, wxID_FRAME1LISTBOX1,
] = [wx.NewId() for _init_ctrls in range(4)]
class Frame1(wx.Frame):
def _init_ctrls(self, prnt):
# BOA generated methods
wx.Frame.__init__(self, id=wxID_FRAME1, name='', parent=prnt,
pos=wx.Point(400, 400), size=wx.Size(500, 400),
style=wx.DEFAULT_FRAME_STYLE, title='改系统hosts,需要把要修改的hosts文件放在hosts目录下面')
self.SetClientSize(wx.Size(750, 300))
self.listBox1 = wx.ListBox(choices=[], id=wxID_FRAME1LISTBOX1,
name='listBox1', parent=self, pos=wx.Point(10, 10),
size=wx.Size(200, 240), style=0)
self.t1 = wx.TextCtrl(self, -1,"",size=(520, 280), pos=wx.Point(220, 10),style=wx.TE_MULTILINE|wx.TE_PROCESS_ENTER)
'''列表目录中所有文件'''
for i in os.listdir('./hosts/'):
self.listBox1.Append(i)
self.listBox1.Bind(wx.EVT_LISTBOX, self.OnListBox1Listbox,
id=wxID_FRAME1LISTBOX1)
self.button2 = wx.Button(id=wxID_FRAME1BUTTON2, label='改写系统hosts',
name='button2', parent=self, pos=wx.Point(10, 260),
size=wx.Size(200, 30), style=0)
self.button2.Bind(wx.EVT_BUTTON, self.OnButton2Button,
id=wxID_FRAME1BUTTON2)
def __init__(self, parent):
self._init_ctrls(parent)
def OnListBox1Listbox(self, event):
selName = './hosts/' + self.listBox1.GetStringSelection()
#self.SetTitle(selName)
f = open(selName, "r+")
try:
all_the_text = f.read( )
finally:
f.close()
self.t1.Clear()
self.t1.write(all_the_text)
def OnButton2Button(self, event):
x = os.getenv('WINDIR')+"\system32\drivers\etc\hosts"
v = self.t1.GetValue();
v = v.encode('gb2312')
f = open(x, 'w')
f.writelines(v)
f.close( )
#--------------- end of class Frame1 --------------------
# program entry point ...
if __name__ == '__main__':
app = wx.PySimpleApp()
wx.InitAllImageHandlers()
frame = create(None)
frame.Show()
app.MainLoop()
访问GOOGLE相册
1. win+r
notepad.exe C:\WINDOWS\system32\drivers\etc\hosts
2. 增加
203.208.39.99 lh1.ggpht.com lh2.ggpht.com lh3.ggpht.com lh4.ggpht.com lh5.ggpht.com lh6.ggpht.com lh7.ggpht.com
203.208.39.99 lh8.ggpht.com
重启浏览器
同事提供的题目(Taobao)
alert(toRGB("#0000FF")); //返回rgb(0,0,255)
alert(toRGB("#00F")); //返回rgb(0,0,255)
alert(toRGB("#FF0000")); //返回rgb(255,0,0)
alert(toRGB("taobao")); //返回rgb(taobao)
alert(toRGB("#G00")); //返回rgb(#G00)
function toRGB(color){
//第有一字符有#号
if(color.indexOf('#')==0){
//判断长度
if(color.length==4){
//取出字母
r = color.match(/([\da-z])/ig);
}else{
//取出字母
r = color.match(/([\da-z]{2})/ig);
}
//返回
return 'rgb('+formatHEX(r) +')';
}else{
return 'rgb('+color+')';
}
}
//转化色彩数组转为10进制
function formatHEX(x){
var html=[];
for(i in x){
html[i] = parseInt(x[i], 16);
if(isNaN(html[i])){
return '#'+x.join('');
}
}
return html.join(',');
}