0%

由于恶意的自动弹出各种小广告窗口实在过于泛滥,因此各浏览器平台默认都是阻止自动弹出新窗口的。but,如果用户主动点击打开新窗口,那么再进行阻止就有些不合情理了。so,用户主动触发的弹出新窗口不会被阻止,如果是代码自动触发则不会如此幸运了。

各大浏览器的默认阻止策略见参考[1],因此如果不想弹出的新窗口被浏览器阻止,可以这样来:

当然最简单就是直接写在元素的onclick事件里,当用户点击时就可以弹出了。

再进一步,可以搞一个隐藏按钮,其click事件为弹出新窗口,然后在另一个用户动作事件中,处理完其他事务后,用javascript调用隐藏窗口的click事件,这样也是可以的。但是就算这样,用setTimeout自动触发也是不行的,也就是必须要在一个用户触发的上下文里弹出窗口才不会被阻止。

用户触发上下文中,调用ajax请求,在ajax的回调函数中打开新窗口时,各个浏览器的反应各有不同,chrome是允许的,而firefox则进行了拦截。这是可以在ajax请求前先弹出空白窗口,ajax请求之后再设置window.location为想要的URL。

References:
[1]window.open() 与浏览器阻止弹出窗口

===
[erq]

CSS有几个控制分页的属性page-break-before,page-break-after和page-break-inside,要注意使用这些属性时一定要使用在块级元素上。只有firefox对inline元素也有效,而chrome和safari则只在block元素上生效,大坑啊,那就用div好了。

贪婪匹配模式会尽可能多的匹配结果,非贪婪模式则相反,尽可能少的去匹配。

以下这些为贪婪匹配,参见:help /\{

1
2
3
4
5
\\{n,m} Matches n to m of the preceding atom, as many as possible
\\{n} Matches n of the preceding atom
\\{n,} Matches at least n of the preceding atom, as many as possible
\\{,m} Matches 0 to m of the preceding atom, as many as possible
\\{} Matches 0 or more of the preceding atom, as many as possible (like *)

以下这些为非贪婪匹配,参见:hep /\{-

1
2
3
4
5
\\{-n,m} matches n to m of the preceding atom, as few as possible
\\{-n} matches n of the preceding atom
\\{-n,} matches at least n of the preceding atom, as few as possible
\\{-,m} matches 0 to m of the preceding atom, as few as possible
\\{-} matches 0 or more of the preceding atom, as few as possible

因此*.\{-}可以实现.的非贪婪匹配,.\{-1,}可以实现.+的非贪婪匹配

===
[erq]

带有datalist的input即是html原生的combobox,再也无需用select+input来模拟combobox了。

而且每个option还可以有label。

就像下面这样:

源代码:
[html]



[/html]

当前主要的浏览器中只有safari还完全不支持datalist,可以使用webshimHTML5垫片程序提供支持。

检测浏览器是否支持datalist
[javascript]
if (‘options’ in document.createElement(‘datalist’)) {
// supported!
}
[/javascript]

References:
[1] THE ALL-IN-ONE ALMOST-ALPHABETICAL GUIDE TO DETECTING EVERYTHING
===
[erq]

inline-block流式布局明显优于浮动布局,float可以休矣!

上次dataguard主备切换时,将job_queue_processes设置为0,关闭了job背景进程。切换完毕后忘了重新设置此参数,导致所有job都停止了,今天才发现。

1
sql> alter system set job_queue_processes=20 scope=both;

这样job就可以恢复正常运行了!

markdown的精髓是内容和表现形式的分离,让写作者更专注于内容而不受或少受展现格式的影响。