2008 年 06 月

浏览模式: 标准 | 列表 | 图文
为自己添加协议

为自己添加协议

原文地址:http://kb.mozillazine.org/Register_protocol

A protocol is a method that is used to send, receive, and handle information over a connection. Common protocols viewed from the browser include http, https, ftp, and mailto. In order for you to view information sent over a specific protocol, it must be registered. If you enter a URL for an unknown protocol (foo) in the Location Bar, you will receive a message such as, Firefox doesn't know how to open this address, because the protocol (foo) isn't associated with any program or, in Mozilla Suite/SeaMonkey, foo not a registered protocol.

Once registered, the protocol can then be handled by the program you specify, such as your browser or a third party viewer. This means that a hyperlink ( e.g. foo://fred) can use the handler for protocol foo to open the file named fred.

Windows

On Windows, protocol registration is done by the operating system (OS). For example, when you set a web browser as the default browser, the OS will register the http, https and ftp protocols and associate them with that web browser; when you open an http https or ftp link in a mail message or from an Internet Shortcut, the URL will open in your default browser. Similarly, when you set a default mail client, the OS registers the mailto protocol so that mailto links in the browser open in the associated mail application.

Note: Mozilla Suite/SeaMonkey integrates mail and browser functions so that web links in an email message (e.g., http:// links) will open in a SeaMonkey browser window and "mailto:" links in a web page will open in SeaMonkey Mail, regardless of the OS protocol handlers.

Other protocols can be registered and associated with an external application by configuring an installed program to handle the content. For example, you can set RealPlayer as the registered protocol handler for RTSP URLs (Real-Time Streaming Protocol) by using RealPlayer's preference settings under "Content -> Media Types". When you next open an rtsp:// link, Firefox or Mozilla Suite/SeaMonkey will ask you to confirm the external protocol request before it will launch the application [1] [2].

It is also possible to register a protocol by creating a .reg file such as the following, and placing this in the file:

REGEDIT4

[HKEY_CLASSES_ROOT\foo]
@="URL:foo Protocol"
"URL Protocol"=""

[HKEY_CLASSES_ROOT\foo\shell]

[HKEY_CLASSES_ROOT\foo\shell\open]

[HKEY_CLASSES_ROOT\foo\shell\open\command]
@="\"C:\\Program Files\\Application\\program.exe\" \"%1\""

Replace foo with the protocol you're specifying and C:\\Program Files\\Application\\program.exe with the program you want to run. [3] Note that backslashes must be doubled and the additional slashes and quotes before the path must not be removed. Save the file, then double-click it to insert into the Windows registry. See Registering an Application to a URL Protocol for additional information.

Linux and Mac

  • Type about:config into the address bar and press Enter.
  • Right-click -> New -> Boolean -> Name: network.protocol-handler.external.foo -> Value -> true (Replacing foo with the protocol you're specifying)
  • Right-click -> New -> String -> Name: network.protocol-handler.app.foo -> Value -> /path/to/app (Replacing foo with the protocol you're specifying and /path/to/app with the path to the application you want to run.
  • Ensure network.protocol-handler.expose-all is set to true.

Troubleshooting

  • (Linux and Mac) If the path or name is incorrect when setting the network.protocol-handler.app.(protocol) preference , Firefox will display an error saying "protocol (foo) isn't associated with any program". (bug 312953)
  • If you receive a message in Firefox that the mailto protocol is not associated with any program, reset your default mail client. [4]
  • Certain unsafe protocols are ignored by default (bug 173010).

See also

External links

The protocol is not associated with any program (Firefox Support)

为JQuery的cycle插件作图片自动缩放

为JQuery的cycle插件作图片自动缩放

function showImg(){
pw = parseInt( $(this).parent().css('width') );
ph = parseInt( $(this).parent().css('height') );
showImage = new Image();
showImage.src = $(this).children('a').children('img').attr('src');
sw = showImage.width;
sh = showImage.height;
//原先这些sw是直接用 $(this).width()来判断,但实际上很多时间都取回的是pager里面的图片大小属性,或者取回来有不正常的时候,这是cycle的BUG,没有时间却验证了,因此,只有用Image类来进行处理,这样取回来的就是图片真正的大小
idx = $('#bigPic li').index( $(this) );
alert(showImage.src+' - '+sw+' - '+sh);
if (sw > pw || sh > ph){
if (sw > sh ){
sh = Math.floor(sh * ( pw / sw ));
sw = pw-10;
}else {
sw = Math.floor(sw * ( ph / sh ));
sh = ph-10;
}
//实在不知道这里为什么会多出16px,如果不减6,就会每次缩小
//这里的长宽比例会不正确。。。
$(this).children('a').children('img').css({'width': sw,'height':sh,'paddingTop':3});
}
if (sh <= ph){
$(this).css('marginTop',(ph - sh)/2).css('verticalAlign','middle');
}
if (sw <= pw){
$(this).css('marginLeft' , (pw - sw)/2).css('textAlign','center');
}
if( idx == 0 ){
$('#thumbnail a').trigger('click');
}
}

Mark it ,and update it on work time...

长时间不更新,送上点JS

长时间没有更新了,一是因为单位比较忙二来是老婆快生了。。

但一直不更新也不太好,这里送上一小段JS,FOR jQuery。

很多时候,我们需要在一堆图片列表里进行左移右移,比如我现在有10个IMG,我放到DIV里面默认显示5个,这时候我会在页面上留下两个按钮进行左移,右移,以前的移动可能会很复杂,自从有了jquery,一切变得这么简单。

<div id="pic_list">
<span id="p_left"> << </span>
<ul>
<li><img src="aa.jpg" /><li>
<li><img src="aa.jpg" /><li>
<li><img src="aa.jpg" /><li>
<li><img src="aa.jpg" /><li>
<li><img src="aa.jpg" /><li>
<li><img src="aa.jpg" /><li>
<li><img src="aa.jpg" /><li>
<li><img src="aa.jpg" /><li>
<li><img src="aa.jpg" /><li>
<li><img src="aa.jpg" /><li>
</ul>
<span id="p_right"> >> </span>
</div>
<script language="JavaScript">
<!--
$('#p_left').click(function(){
var list_length = $('#pic_list ul li').length;
$('#pic_list ul li:eq(0)').before( $('#pic_list ul li:eq('+(list_length-1)+')').remove() );
});
$('#p_right').click(function(){
$('#pic_list ul').append( $('#pic_list ul li:eq(0)').remove() );
});
//-->
</script>

具体样式我就不提供了,黑黑,这样的方法应该算是最简单的了。。毕竟你在做页面的时候,肯定会都把li的宽度设的一样

Smarty的一些常用方法

Smarty的一些常用方法

网上流传的大师兄教程确实给了我们很多方便,只是大师兄教程却不是很全面。或许他给很多设计师们带来了福音,但对程序开发人员来说,并没有什么特别的高深之处。

不过,我还是挺佩服他的,毕竟,他将自己的思想和实现方法提供出来,如果每个人都这样,或许,我们能够再进步一些。呵呵

在工作,仍然是在使用着smarty,也在开发中积累了一点点的心得,逐步写出来,与大家共同分享,当然应该会存有错误,与大家一起改进。

smarty在使用时是需要配置的,最简单的配置方法就是将基本的变量写成一个数组,然后new Smarty之后,foreach一下,由$smarty自行加载,如:

---------------------------------------------

辛苦写了半天,结果超时了。下次补上,今天没时间了。