BMTD 's Yard of Fun

Technology, Sports, Music, Chinese Essays

Browsing Posts in IT

In my last blog post ( I used user styles to create a “closeable kiosk” with firefox. Google chrome also supports user styles so similar styles can be applied to Chrome too.

Both firefox and Chrome support another “user scripts”, which “Allows you to customize the way a web page displays or behaves, by using small bits of JavaScript.”. it can be applied to selected pages only, or to all the sites/pages. Here is a way to use user scripts to create a “closeable kiosk.”

steps for chrome:
(1) install the chrome extension “TamperMonkey” from
(2) compose a new user script with the following code:

/ ==UserScript==
// @name       closeit
// @namespace
// @version    0.1
// @description  close buton
// @copyright  Jie Li
// ==/UserScript==

var closeButton = document.createElement( 'img' ); = 'myCloseButton';
closeButton.title= 'Close the Window';
closeButton.src= '';
    ' #myCloseButton {            ' +
    '    position: fixed;    ' +
    '    top: 2px; right: 8px;   ' +
    '   z-index:1000;   ' +
    ' } '
closeButton.addEventListener( 'click', function () {'', '_self', '');
}, true );

document.body.appendChild( closeButton );

and click on “settings” tab on the script editor, choose “yes” for “Run only in top frame”. and then enable the script.

for firefox, it’similar, just replace TamperMonkey with the firfox addon “greaseMonkey”.

now if you open the browser in kiosk mode ( fore chrome it needs to be started from command line option “–kiosk”), there is always a big round red “X” close button at the top right corner. clicking on it will close the browser. see screen shot below:

Recently I got request to create a “closeable browser-based kiosk”– basically a browser in full screen mode, can’t be minimized/resized/moved or returned to non-full screen mode, no browser file menus, no address bar/navigation bar so user have to be stay on the same page, and can’t go to other urls. However user should be able to close it using mouse. This is to be deployed on some real kiosk booths like the ones often seen in a museum. There is no keyboard on the kiosk so short cut key combinations like alt-F4 won’t work.

Browsers like Chrome or Internet Explorer already have the built-in kiosk feature. for IE it’s the -k option; for Chrome there is the –kiosk option. if you start the browser with these options you will see the browser in kiosk mode. for firefox, there is the r-kiosk addon. Problem is that there is no way to close the browser with just a mouse once you are in kiosk mode.

One simple solution is to use firefox ‘s userscripts feature to create my own closeable kiosk mode.

the steps are:

(1) from firefox menu. option “tools”–>”options”–>”privacy”–>history, for “firefox will” dripdown, choose “use custom settings for history”, then choose the option (checkbox) “clear history when forefox closes”, then click OK button.

(2) install the “stylish” firefox extension from

(3) open stylish add on, click “write new style”, an editor will open. enter the following code in the editor, then save the style and enable it.

@namespace url(;
@media not all and (-moz-windows-compositor){

.statuspanel-label {display:none !important;}
#nav-bar {display:none !important;}
#navigator-toolbox {display:none !important;}
#urlbar-container, #openLocation {display:none !important;}
#minimize-button,#restore-button,#close-button {display:none !important;}

#titlebar-max, #titlebar-min {display:none !important;}

now if you start firefox you will see a “closeable kiosk”. for example, “firefox https//” you will see the following “kiosk” with only the “X” close window icon on the title bar:

There are other ways to do this as well. For example, we can write some UserScripts in firefox or Chrome to inject some “close window” button onto al the web pages. so that user can always close the browser with mouse even in the native browser kiosk mode. Will give an example how that works later.


No comments


my first iphone app, for….

It’s in app store now:

我得第一个iphone app : 海龟网iphone app正式上线, 可从app store 免费下载安装

大家可以在iphone上的app store 里搜索“归网”,然后免费下载安装。谢谢各位支持。


注: 在ios4.2 以上版本的iphone/ipod touch 上测试过。其他版本的ios未经测试。

-- 虽然海归网总的感觉是在没落中,但是还是有不少的新老id在这里玩。。。这种亲切感挥不掉。希望通过这个小程序让大家玩得更方便一点。
-- 很不喜欢apple的xcode, 特别是interface builder. 个人觉得很垃圾。
-- objective-c 本身还是不错的语言,有不少好的动态特性;但内存管理比较乱,初学者很易摆乌龙。这点来说要不象c/c++那样完全显式分配、释放内存,要不象java/.net那样garbage collection; objective-c 的ref count 以及assign/copy之类很容易让人晕坨坨.
--这是第一个moble app. 主要是体会一下在移动平台上开发的感觉,为有朝一日真正做商业产品的时候积累些经验。
-- 以后再做手机程序,除非用到一些特别功能, 可能最好用一些跨平台开发工具, 比如说 phonegap( , rhomobile ( )

不通过应用程序而纯粹从简单服务器配置。。。transparent to your apps

1. 用 apache mod_rewrite 实现根据用户ip自动选择镜像


在 apache config 里加一个 virtual host:

    <virtualhost *:80>
        DocumentRoot /hosting/balance
               ServerName balance
    <filesmatch "\.(php|htm|html|pl|asp)">
        Allow from all

        RewriteEngine on
    RewriteLog rewrite.log
    RewriteLogLevel 9
        RewriteMap    lb      prg:/hosting/balance/ip_prg.php
        RewriteRule   ^(.*)$ ${lb:$1} [P]
        CustomLog "logs/balance_access.log" combined
        ErrorLog "logs/balance_error.log"

then I have a simple php script ip_prg.php (as configured in apache shown above) to do the redirection:
continue reading…