it-e-46 Object-oriented programming

Object-oriented programming (OOP) refers to a special type of programming that combines
data structures with functions to create re-usable objects.
Otherwise, the term object-oriented is generally used to describe a system that deals primarily
with different types of objects, and where you can take the actions depends on what type of object
you are manipulating. For example, an object-oriented draw program might enable you to draw
many types of objects, such as circles, rectangles, triangles, etc. Applying the same action to each of
these objects, however, would produce different results. If the action is Make 3D, for instance, the
result would be a sphere, box, and pyramid, respectively.
Many languages support object oriented programming. In OOP data and functions are
grouped together in objects (encapsulation). An object is a particular instance of a class. [1] Each
object can contain different data, but all objects belonging to a class have the same functions
(called methods). So you could have a program with many e-mail objects, containing different
messages, but they would all have the same functionality, fixed by the email class. Objects often
restrict access to the data (data hiding).
Classes are a lot like types the exact relationship between types and classes can be complicated
and varies from language to language.
Via inheritance, hierarchies of objects can share and modify particular functions. You may
have code in one class that describes the features all e-mails have (a sender and a date, for
example) and then, in a sub-class for email containing pictures, add functions that display images.
[2]Often in the program you will refer to an e-mail object as if it was the parent (super-class)
because it will not matter whether the e-mail contains a picture, or sound, or just text. This code
will not need to be altered when you add another sub-class of e-mail objects, containing (say)
electronic cash.
Sometimes you may want an action on a super-class to produce a result that depends on
what sub-class it "really is". For example, you may want to display a list of email objects and
want each sub-class (text, image, etc) to display in a different colour. In many languages it is
possible for the super-class to have functions that sub-classes change to suit their own purposes
(polymorphism, implemented by the compiler using a technique called dynamic binding). So
each email sub-class may supply an alternative to the default, printing function, with its own
colour.
In many OO languages it is possible to find out what class an object is (run time type
information) and even what functions are connected with it (introspection / reflection). Others,
like C++ have little run time information available (at least in the standard language individual
libraries of objects can support RTTI with their own conventions).
[3]There are at least three approaches to OO languages: Methods in Classes, Multi-Methods
Separate from Classes, Prototypes.

Many languages follow Smalltalk in associating functions (methods) with classes. The
methods form part of a class definition and the language implementation will have (this is a
low-level detail hidden from the programmer) a vtable for each class which links methods to their
implementations. This indirection is necessary to allow polymorphism, but introduces a
performance penalty. In some languages (C++, at least), only some methods, marked as virtual
by the programmer, are treated in this way.

Some languages (e.g. common Lisp / CLOS) allow functions to specialise on the class of
any variable that they are passed (multi-methods). Functions cannot be associated with one class
because different versions of the function may exist for many different combinations of classes.

Other OO languages do away with classes completely (e.g. Self). Prototype-based languages
create new objects using an existing object as an example (prototype). Apart from solving some
problems with dynamic object creation, this approach also encourages delegation (function calls
are passed to other objects) rather than inheritance.

没有生词

Continue reading it-e-46 Object-oriented programming

【转】苹果iOS平台成功的应用程序特性大整理

iOS平台目前主要泛指iPod Touch、iPhone以及iPad这三种主要的机型,近日开始研读起iOS Human Interface Guide(后简称HIG)的相关章节,发现其实有许多一般入门时常见的问题,其实都可以在这里获得解答。兹就经验上许多人可能会产生的疑问,并配合上述 HIG文件内容进行一份整理。 如同「平台特性(Platform Characteristics)」章节开头所明述的,成功的应用程序将会拥抱这些特性,并融合在让用户在操作装置之间,所以熟知iOS上的平台特性,合理的设计以及运用其在自己所开发的应用程序中,将会对于用户在操作应用程序时,有大大的帮助。
屏幕显示关乎一切
这部份几乎是无庸置疑的,iOS平台上的操作,几乎都是在屏幕上执行,下面3点可以给iOS诸平台适用的:
◆最舒适的点击区域大小是 44 x 44 点 (Points而非Pixels)
◆应用程序的图片设计影响是很明显的
◆使用者专注在内容上
以下是常见的iOS装置屏幕尺寸:

screensize
装置显示方向
基本上,原则就是Home Screen如何,进入应用程序的默认显示方向就会是如何。
◆由于iPhone以及iPod Touch的主画面(Home Screen),只会有一种显示方向,所以默认进入到应用程序时,就应该会是直立向。
◆在iPad上由于主画面可以是全方向,所以用户预期进入应用程序时,方向会有一致性。
不用学习的基本操作手势
使用者不会去发掘特殊的操作手势,就算偶尔发现非一般手势,并惊呼原来可以这样做时,也只是偶尔,所以让人们拥有连贯性的使用经验,利用所有iOS内建的原有手势,是让应用程序成功的主要因素,下面的表格是一些基本的手势。
苹果也指出,虽然所有iOS装置都支持多点触控的手势,大屏幕提供比较多手指运作的空间,但不代表多指的手势比较好;猜测使用者不会知道或者在大多数场合,使用者还是习于一手一指走天下。

actions

◆如果想看更多手势,以及其他行动平台上的手势,或许可以参考LukeW的这份文件

         人们一次只会跟一个应用程序互动
对,这听起来的确是很废话,在使用者的面前,只会有一个应用程序在前台与用户互动。在iOS 4之前,应用程序被关掉之后,就会被从内存中移除;但iOS 4之后,他可能会在背景继续执行,这个一般称之为多任务(Multitasking),应用程序通常会在背景执行直到他们下次被呼叫出来,或者直接被终止工作才会停止运作。
在主画面中,快速按Home Screen圆钮两次,就可以叫出位于画面最底端的多任务选单,使用者可以快速的找到最近用过的应用程序。当用户再一次使用这些应用程序的时候,这些程序就不用再重新被加载,而是会被从他们上次跳出的地方进入。
而有些应用程序是要在背景继续被执行的,像是音乐程序,用户会希望在查询日历或信件的同时,还是可以听到他们喜爱的音乐在背景播放。
偏好(Preferences)可以在设定(Setting)中被找到
在设定里的「偏好」通常是设好一次后,就很少被变动的设定。虽然一些内建的应用程序有这类型的偏好设定,不过大部份的应用程序并不太需要这类东西。
极少化屏幕上的帮助功能
移动装置的用户,其实不会花太多时间去研究到底应用程序里整体有什么功能,所以除非他们有感觉到获得好处或好用,接着才会到利用所谓的帮助功能,iOS装置以及内建应用程序都被设计得非常直觉并易于使用,所以依此类推,所有应用程序都应该被以这种少说明甚至是无说明的方式在执行。
在iOS上的两种软件
在iOS上,依照着不同的执行方式,开发者可以有两种开发iOS软件的方式:
◆iOS应用程序
◆网站内容
iOS应用程序是利用iOS SDK开发的应用程序,也可以称之为原生应用程序(Native App),由于这些iOS应用程序重组了内建应用程序的特色,所以依附在装置上之时,就可以在iOS环境下有特别的优势。人们会把这些应用程序当作像内建的相簿、行事历以及信箱。
网站内容则是主要由一个网站提供内容,但是透过iOS装置浏览。又可以分成3种形态:
◆网站应用程序(Web apps),行为近似于iOS应用程序,一般的网站应用程序通常会隐藏Safari浏览器的接口,让他看起来像是原生的应用程序。
◆优化网页(Optimized webpages),网页有针对iOS上的Safari浏览器进行优化,并移除一些不被支持的效果,像是Plug-In、Flash以及Java。更甚者,还会针对屏幕大小进行内容的排版调整等,以使得在装置上可以被最佳的阅读。
◆兼容网页(Compatible webpages),这是与上者相对的,网页可以在iOS上被浏览,但是通常会遇到一些无法支持的元素,排版之类的也不见得会适合在装置上阅读,但是通常都可以被显示出来。 在iOS用来浏览网页的Safari
iOS上的Safari与一般桌面计算机使用的Safari不尽相同。主要可以观察点包含:
◆使用者无法任意的调整可视画面的尺寸,一般的浏览器,使用者可以拖拉浏览器窗口的大小来调整尺寸。在iOS上,只能透过显示方向来改变。
在iOS上的Safari支援cookies。
在iOS上的Safari不支持 Flash、Java(含Java applets)或者第3方的网站内容插件。但支持HTML 5的以及 标签以提供影音串流,以及JavaScript、CSS 3以显示动画内容。
◆有些像是鼠标滑过(Hover)这样的动作是不存在iOS上的。
◆iOS上的Safari允许网页应用程序以全屏幕执行,如果用户有把某网站设到主画面中作为图示,就可以隐藏Safari的接口,这会使其看起来更像是原生应用程序。

Continue reading 【转】苹果iOS平台成功的应用程序特性大整理

IPhone In Action 读书笔记

1章介绍,2-9章web,10-20章sdk(sdk tools)

mac os基于unix发展

480*320 像素输出屏幕。

wifi→EDGE(Enhanced Data Rate for GSM Evolution,增强型数据速率GSM演进技术,最大220kbps)→3G(384kbps--1000kbps)

web开发工具 iui http://code.google.com/p/iui/(web库) ,dashcode(IDE)

safari不支持java,flash.

1.4.1 web视图是980px缩放的效果?

Chrome头所占比率

            带url   不显示url

竖向 26%      13%

横向 35%     16%

作者倾向横向,Chrome头可以通过动态显示解决。

没有鼠标的概念,也没有滚动条。

第六章介绍了canvas

第九章初步介绍了 objectC

支持类方法(静态方法)

消息类似于方法

更加明确的演绎MVC模式

限制:

不能下载非sdk代码(这导致java不能运行在iphone上)

必须经过用户允许才能获得用户位置

不能进行实时路由引导

不能包含ip voice功能

开发者需要证书才能提交程序,但是apple可以回收此证书(如果不喜欢你开发的程序)

ios架构:

image

10.3.1

大部分将UI操作会和Cocoa Touch打交道,但是也有要使用ObjectC类的情况,这就在Core Foundation(类名以CF开头)之上了。

Cocoa Touch包含 UIKit(类名以UI开头)和Foundation(类名以NS开头)

16章讲了sqlite,包含数据类型转换的内容。

这部书主要讲应用程序,没有讲游戏相关。

第十九章讲图形 Quartz 2D,openGL等

Quartz 2D建立在老的Core foundation之上??

三个概念context,pathes,state

cocos2d是封装的openGL,也用到了quartz 2D

Quartz默认的坐标系是从右下到左上,与Cocoa Touch整好相反。如果你不是使用Cocoa Touch创建context,就要认为坐标原点是右下。

图context保存为堆形式(先进先出)

19.4.4图形变换

19.4.5 状态管理 save,restore.--和canvas2d像吧

高级2D:梯度,图片处理,画字

19.7 动画介绍

19.8 OpenGL ES(Embded System)

EAGL is Embedded AGL(Apple's OpenGL extensions for OS X.)

openGL通过EAGLView操作,也就是UIView的CAEAGL层。

Xcode提供了OpenGL的模板,默认设置了它的参数,只要在EAGLView的drawView方法里写你的代码就行了。

详细见apple文档OpenGL ES Framework Reference,里面也有示例。

Continue reading IPhone In Action 读书笔记

iphone 那些事

买了iphone到现在有差不多一个星期了,到今天才知道这个iphone越狱成功了。现在回忆一下,说实话,自己都还是糊里糊涂,不知道什么回事。

主要的教程在http://iphone.tgbus.com/Special/20gujian/ 上找,

按照他的来,不懂得再google, 越的时候比较难操作的是进入DFU模式,那真叫技术活。

就这样还算顺利,没有白苹果,就装上了cydia。

下一步开始更新cydia,但没wifi 怎么办,最后发现win7下Connectify可以直接做热点,哈哈,wifi是好了,但是cydia还是说什么网络错误。我找了新的源,任然如此。没办法,就按照http://bbs.weiphone.com/read-htm-tid-443797.html里面提到的离线安装模式,使用iFunBox装了ipa补丁。

然后下了个植物大战僵尸破解版,按照说明安装,嘿嘿,既然可以了。

这时才知道--哦,原来越成功了啊!

Continue reading iphone 那些事

it-e-45 How to Learn a New Language

How do you learn a new language? The fastest way is when you are forced to do so. But if
you're lucky enough to be learning by choice, you are probably doing it in your spare time and
you won't do that unless you are enjoying yourself  so choose an interesting project.
Choosing what you are going to write in your new language is more important than
choosing the language. Choose the language to suit the project or, better, choose both together.
For example, if you want to write something that will look good then don't choose a language
with no support for graphics.
Learn a little about the language before you start and try and find a solution that will play to
the language's new features. If you are using OOP for the first time, for example, try and think
how your project can be split into objects. If you are looking at functional programming, maybe a
numerical project would be a good start (I chose cryptography) (this suggestion does not imply
that functional languages are only useful for numerical code, just that most textbooks seem to
feature numerical examples in my limited experience making it easier to start in that
direction).
At the same time, be honest with yourself. Don't be too ambitious don't pick too difficult a
project and (maybe) don't pick too exotic a language. The second point is debatable. With any
language you will learn something new: it doesn't have to be a huge intellectual leap into the
unknown. You are going to be more productive in a language that has some familiar ideas, and
you can lean on that part of the language to get going. On the other hand, if you enjoy new ideas,
maybe you will be happier with something completely different.
Support is also important. If you intend to post questions to Usenet, is there an appropriate
newsgroup? Personally, I like booksÇthe best impetus for me is finding a good book on
computing that uses a particular language in the examples.
A note about asking for information on newsgroups: people seem to vary widely in how
precisely they talk about languages. At one end of the spectrum there are people who tend to rely
on a "subconscious" (or at least "sub-language") intuition and happily misuse terminology to "get
the idea across". At the other end are people who are very precise. Both, no doubt, will give
conflicting advice on how to learn and, sometimes, apparently conflicting answers to questions.
You have to learn to recognise different styles and read them in the context of the poster.
Finally, don't be afraid to change direction. I've stuck with a few languages much more than
with others. Sometimes I have given up in frustration. But even when you only play around a
little, you learn something. My argument is not that you must stay with a language a long time
to learn anything, but that the learning continues. Stay for a while and you'll learn something.
Stay longer and you'll learn more. there's no magic moment when you know everything (which
is what makes programming such a rewarding profession).

1, exotic  [,iɡ'zɔtik]
adj. 异国的;外来的;异国情调的

2, misuse  [,mis'ju:z, ,mis'ju:s]
vt. 滥用;误用;虐待
n. 滥用;误用;虐待
3, terminology  [,tə:mi'nɔlədʒi]
n. 术语,术语学;用辞
4, subconscious  [,sʌb'kɔnʃəs]
adj. 潜意识的;下意识的
n. 潜在意识;下意识心理活动
5, frustration  [frʌs'treiʃən]
n. 打破,挫折,顿挫
[计算机] 失败

Continue reading it-e-45 How to Learn a New Language

it-e-44 A Brief Word About Scripting

You've perhaps heard about something called scripting, or maybe you've heard of languages
like JavaScript, VBScript, Tcl and others (those languages are called scripting languages). You
may thus be wondering if scripting is the same as programming, and/or what the differences are,
and so on. People get quite passionate about this question, so I'm just going to cover it briefly and
technically. Here are some facts:
Scripting is essentially a type of programming.
Scripting languages have a few minor technical differences which aren't important to
discuss at this point.
Scripting languages tend to be interpreted rather than compiled, which means that you
don't need to compile them. they're compiled "on the fly" (i.e. when necessary, right
before they're run). This can make it faster to program in them (since you always have
the source code, and don't need to take the deliberate extra step of compiling).
The fact that scripting languages are interpreted generally makes them slower than.programming
languages for intensive operations (like complex calculations).
Scripting languages are often easier to learn than programming languages, but usually
aren't as powerful or flexible.
For programming things like applications for personal computers, you'll need to use a
programming language rather than a scripting language.
Scripting languages can be excellent for beginners: they tend to be easier to learn, and they
insulate you from some of the technical aspects of programming (compiling, for one). However,
if you're serious about programming, you won't be able to stay with a scripting language forever
you will move on to a programming language at some point. I'd say that it's good to know a
scripting language or two, and even to start with a scripting language rather than a programming
language. However, there's a point of view which says that, by protecting and "hand-holding" too
much, scripting languages don't properly prepare you for "serious" programming, and set you up
for a bit of a learning curve when you move on to a programming language.

 

1, deliberate  [di'libəreit]
a. 故意的,深思熟虑的
v. 仔细考虑
vt. 研讨

Continue reading it-e-44 A Brief Word About Scripting

it-e-43 Introduction of Programming Languages

A programming language is a defined set of instructions that are used to make a computer
perform a specific task. Written using a defined vocabulary the programming language is either
complied or interpreted by the computer into the machine
language that is understood by the processor.
There are several types of programming languages, the
most common are:
High-level Languages these are written using terms
and vocabulary that can be understood and written in a

similar manner to human language. [1] They are called high-level languages because they remove
many of the complexities involved in the raw machine language that computers understand. The
main advantage of high-level languages over low-level languages is that they are easier to read,
write, and maintain. All high-level languages must be compiled at some stage into machine
language. The first high-level programming languages were designed in the 1950s. Now there are
dozens of different languages, including BASIC, COBOL, C, C++, FORTRAN and Pascal.
Scripting Languages like high-level languages, scripting languages are written in manner
similar to human language. Generally, scripting languages are easier to write than high-level
languages and are interpreted rather compiled into machine language. Scripting languages, which
can be embedded within HTML, commonly are used to add functionality to a Web page, such as
different menu styles or graphic displays, or to serve dynamic advertisements. These types of
languages are client-side scripting languages, affecting the data that the end user sees in a
browser window. Other scripting languages are server-side scripting languages that manipulate
the data, usually in a database, on the server. Scripting languages came about largely because of
the development of the Internet as a communications tool. Some examples of scripting languages
include VBScript, JavaScript, ASP and Perl.
Assembly Language assembly language is as close as possible to writing directly in
machine language. Due to the low level nature of assembly language, it is tied directly to the type
of processor and a program written for one type of CPU generally will not run on another.
Machine language The lowest-level programming language. Machine languages are the only
languages understood by computers. While easily understood by computers, machine languages are
almost impossible for humans to use because they consist entirely of numbers. Programmers,
therefore, use either a high-level programming language or an assembly language. An assembly
language contains the same instructions as a machine language, but the instructions and variables
have names instead of being just numbers.
Programs written in high-level languages are translated into assembly language or machine
language by a compiler. Assembly language programs are translated into machine language by a
program called an assembler.
Every CPU has its own unique machine language. Programs must be rewritten or recompiled,
therefore, to run on different types of computers.
For now, let's talk about some high level languages very briefly, which are used by professional
programmers in the current mainstream software industry.
· C
This is probably the most widely-used, and definitely the oldest, of the three languages I
mentioned. It's been in use since the 70s, and is a very compact (i.e. not much "vocabulary" to
learn), powerful and well-understood language.
· C++
This language is a superset of C (that just means that it's C with more stuff added; it's more
than C, and includes pretty much all of C). Its main benefit over C is that it's object oriented.

The key point is that object oriented languages are more modern, and using object oriented
languages is the way things are done now in the programming world. So C++ is most definitely
the second-most used language after C, and may soon become the most used language.
· Java
Java has a benefit which other programming languages lack: it's cross-platform. It means
that it runs on more than one platform without needing to be recompiled. A platform is just a
particular type of computer system, like Windows or Mac OS or Linux. Normally, if you wanted
to use the same program on a different platform from the one it was written on, you'd have to
recompile it you'd have to compile a different version for each different platform. Sometimes,
you'd also need to change some of your code to suit the new platform. This probably isn't
surprising, since the different platforms work differently, and look different.
Java has another advantage that it runs inside web browsers, letting programmers create
little applications which can run on web sites. However, Java also has a disadvantage, which is
almost as serious: it's slow. Java achieves its cross-platform trick by putting what is essentially a
big program on your computer which pretends to be a little computer all of its own. The Java
runs inside this "virtual machine", which runs on whatever platform you're using (like Windows
or Mac OS). Because of this extra layer between the program and the computer's processor chip,
Java is slower than a program written and compiled natively for the same platform. Anyway, as
the Internet develops, Java will be used more widely.

 

竟然没有生词

Continue reading it-e-43 Introduction of Programming Languages

自己写html editor

简单的html editor 就是利用iframe的 document属性 designMode = 'on' 来让iframe可编辑。

如下例:

<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<title>自己写Html编辑器</title>
		<script type="text/javascript">
			function init()   
		    {   
		        var doc = document.getElementById("EditForm").contentWindow.document;   
		            doc.designMode = 'on';
		            doc.write('<html><head><title></title><style type="text/css">p {margin: 0;padding: 0;}</style></head><body>fffffffffffffffffffff</body></html>');
		            doc.close();
		    }
		</script>
	</head>
	<body onLoad="init()">
		<iframe id="EditForm" frameborder="0"
			style="width: 700px; height: 400px; padding: 0; margin: 0; border: 1px solid #AAAAAA">
		</iframe>
	</body>
</html>

在IE和opera下,回车形成的行之间是用<p>(FF 下是<br>,chrome,safari是<div>)来包含的,造成行间距太大,因此要使用样式来修正。

第一次设置designMode为on会将document本来的内容全部清除。所以需要将样式表等初始化内容写入文档。

 

inserAtCursor插入文本实现:

IE使用TextRange.pasteHTML

其他使用selectionRange.deleteFromDocument 清空 //opera不起作用,使用Range.deleteContents

使用selectionRange.addRange添加内容

Range.createContextualFragment创建html

Range.inserNode添加节点(节点必须已经存在dom中,否则报错,但是createContextualFragment不存在这个问题)

然而createContextualFragment无法得到Dom节点对象,

insertNode中可以使用DocumentFragment

而selectNode则不行,最终只好换回使用createElement再转移。

但是selectNode在FF,opera下ok,在safari和chrome下就不行了。

只好将插入的内容放入span中,直接对这个span节点selectionRange.selectAllChildren,然后selectionRange.collapseToEnd。

虽然加入了额外的span节点,总算是实现了。

但是看到ext的htmlEditor源码,真是哭笑不得,IE的做的做法和我的一样(Ext的实现有bug)

其他浏览器的一句话搞定doc.execCommand('InsertHTML', false, html);直接略过上述碰到的种种问题。

还是把自己写的留下来做个纪念吧

this.insertAtCursor1 = function(html) {
		this.focus();
		if (isIE) {
			if (!cursel) {
				cursel = doc.selection.createRange();
			}
			cursel.pasteHTML(html);
			cursel.collapse(false);
			cursel.select();
		} else {
			var r = win.getSelection();
			if (r.toString().length) {
				r.deleteFromDocument();
			}
			if (!r.rangeCount) {
				r.addRange(doc.createRange());
			} else {
				// opera
				r.getRangeAt(0).deleteContents();
			}
			var rg = r.getRangeAt(0);
			var tc = doc.createElement('span');
			tc.innerHTML = html;
			doc.body.appendChild(tc);
			rg.insertNode(tc);
			//webkit必须要这样才能将光标移到刚插入内容的末尾,Range.collapse(false)不起作用
			//但是这样造成连续调用insertAtCursor的话,会使刚插入的内容插入到上次创建的span里面嵌套了
			//这种实现不好
			r.selectAllChildren(tc);
			r.collapseToEnd();
		}
	};

 

换行事件:

opera要取消回车事件默认处理的话,除了在keydown里面要调用preventDefault之外,在keypress里面也得调用,否则不起效果(就算stopPropagation,cancelBubble也一样)。

这里使用insertAtCursor(‘<br>’)的方法不能达到换行的目的:

FF,opera不起作用,

其余倒是可以但是调用doc.innerText就得不到换行了。

这时到可以使用上面的selection方法了:

this.newLine = function() {
		this.focus();
		if (isIE) {
			if (!cursel) {
				cursel = doc.selection.createRange();
			}
			cursel.text = '\n';
			cursel.collapse(false);
			cursel.select();
		} else {
			if (cox.isOpera || cox.isGecko) {
				var r = win.getSelection();
				if (r.toString().length) {
					r.deleteFromDocument();
				}
				if (!r.rangeCount) {
					r.addRange(doc.createRange());
				} else {
					// opera
					r.getRangeAt(0).deleteContents();
				}
				var rg = r.getRangeAt(0);
				var tc = doc.createElement('br');
				doc.body.appendChild(tc);
				rg.insertNode(tc);
				/**
				 * opera下这样写反而到导致光标没有移动,不写倒是ok的,
				 * 火狐必须这样写,但是有个bug,如果开始什么都没有内容就换行会导致光标没换行(其实已经插入br了),
				 * 火狐这种写法还导致getText忽略了换行
				 * */
				if (cox.isGecko) {
					rg.selectNode(tc);
					rg.collapse(false);
					r.collapseToEnd();
				}
			} else if (cox.isWebKit) {
				doc.execCommand('InsertText', false, '\n');
			}
		}

Continue reading 自己写html editor

https 跨域问题

http转向https后,原来相对ajax请求仍然是有效地,因为他们是一个域。

例如部署了web项目abc.war到tomcat下面,原来请求http://localhost:8080/abc/index.html

这个页面有ajax请求test.ajax 好,一切ok.

然后你配置了tomcat https端口为8043,你再请求https://localhost:8043/abc/index.html

发现ajax请求也变为https://localhost:8043/abc/test.ajax,一切仍然ok.过渡很平滑是不是。

但是如果你在http://localhost:8080/abc/index.html里面请求https://localhost:8043/abc/test.ajax 那就是跨域了,会执行错误。

另外ie对跨域的要求更严格:

比如给一个图片赋值img.src=’url’

http://localhost:8080/abc/index.html 中将img.src付给https域,则会提示是否允许。

而在https域中将img.src付给http域或其他域则直接导致脚本错误。

这就导致使用https 情况下new Image().src跨域的方式行不通了。

Continue reading https 跨域问题

Pagination


Total views.

© 2013 - 2019. All rights reserved.

Powered by Hydejack v6.6.1