Showing posts with label Options. Show all posts
Showing posts with label Options. Show all posts

Monday, May 24, 2010

rails session options

require 'action_controller/cgi_ext'
require 'action_controller/session/cookie_store'

module ActionController #:nodoc:
class Base
# Process a request extracted from a CGI object and return a response. Pass false as session_options to disable
# sessions (large performance increase if sessions are not needed). The session_options are the same as for CGI::Session:
#
# * :database_manager - standard options are CGI::Session::FileStore, CGI::Session::MemoryStore, and CGI::Session::PStore
# (default). Additionally, there is CGI::Session::DRbStore and CGI::Session::ActiveRecordStore. Read more about these in
# lib/action_controller/session.
# * :session_key - the parameter name used for the session id. Defaults to '_session_id'.
# * :session_id - the session id to use. If not provided, then it is retrieved from the +session_key+ cookie, or
# automatically generated for a new session.
# * :new_session - if true, force creation of a new session. If not set, a new session is only created if none currently
# exists. If false, a new session is never created, and if none currently exists and the +session_id+ option is not set,
# an ArgumentError is raised.
# * :session_expires - the time the current session expires, as a Time object. If not set, the session will continue
# indefinitely.
# * :session_domain - the hostname domain for which this session is valid. If not set, defaults to the hostname of the
# server.
# * :session_secure - if +true+, this session will only work over HTTPS.
# * :session_path - the path for which this session applies. Defaults to the directory of the CGI script.
# * :cookie_only - if +true+ (the default), session IDs will only be accepted from cookies and not from
# the query string or POST parameters. This protects against session fixation attacks.
def self.process_cgi(cgi = CGI.new, session_options = {})
new.process_cgi(cgi, session_options)
end

def process_cgi(cgi, session_options = {}) #:nodoc:
process(CgiRequest.new(cgi, session_options), CgiResponse.new(cgi)).out
end
end

end

Wednesday, April 16, 2008

IE中innerHTML的局限性

IE的相关文档表明,在IE中,innerHTML在以下封闭标签中为只读属性:
1. col
2. colgroup
3. frameset
4. html
5. style
6. table
7. tbody
8. thead
9. tfoot
10. title
11. tr
在这些标签中只能读取到innerHTML内容却无法设置,在其他浏览器却都是可以的。
另外在select标签对中用innerHTML写入option,在IE中是可以写入,但无法正常显示,写入的内容与innerHTML的内容已经不一样,不过将其innerHTML=''赋空值却是可以正确将select原来的options移除。
换一种写法,如:
document.getElementById('select_elem_id').appendChild(new Option(text, value));
这个在IE中也是不可行,在其他浏览器中一切正常。

在IE中,往select中写入options可以用select对象的options属性写入:
document.getElementById('select_elem_id').options[0] = new Option(text, value);
这种方法在其他浏览器里也是一样正确执行。

Friday, December 21, 2007

隐藏Gvim菜单和工具栏

在~/.vimrc(_vimrc)中添加下面几行:
"完全隐藏菜单:
:set guioptions-=m " 可以随时用 :set guioptions+=m 再呼出菜单,下面工具条也类似
"完全隐藏工具栏:
:set guioptions-=T

Sunday, July 15, 2007

select options manuplation of javascript


<form action="" method="get" accept-charset="utf-8">
<strong>Single Robot Choice:</strong>
<select name="robot" id="robot">
<option value="1">Security</option>
<option value="2">Trainer</option>
<option value="3">Friend</option>
<option value="4">Cook</option>
</select>
<br /><br />
<strong>Multiple Robot Choice:</strong>
<select name="robotMulti" id="robotMulti" size="4" multiple="multiple">
<option value="a">Security</option>
<option value="g">Trainer</option>
<option value="s">Friend</option>
<option value="d">Cook</option>
</select>

<input type='button' value='-' name='button1'>
</form>

<script type="text/javascript" charset="utf-8">
function doc (argument) {
document.write(argument);
document.write("<br />\n");
}

function selectedItems (obj) {
var o = obj.options;
var s = '';
for(var i in o) {
if(o[i].selected){
s += 'index="' + i + '": selected options text="' + o[i].text + '", selected options value="' + o[i].value + '"; ';
}
}
alert(s);
}

var select1 = document.forms[0].robot
var select2 = document.forms[0].robotMulti

// doc(select1);
// alert(select2.multiple);

select1.onchange = function () {
alert('selected text = "' + select1.options[select1.selectedIndex].text + '"; selected index="' + select1.selectedIndex + '"; option index ="' + select1.options[select1.selectedIndex].index + '" ');
}

document.forms[0].button1.onclick = function() {
selectedItems(select2);
}

</script>