浏览模式: 标准 | 列表Tag:javascript
Submitted by gouki on 2012, February 11, 9:35 PM
本来不想转,因为我对ruby不熟,但所幸对javascript还略懂一点。看了视频里的js的几个相加,觉得很有趣,比如,[]+[],[]+{},{}+[]等,超级有趣,不信?
看看视频你就会笑了,当然前提你懂编程。。。
原文来自:http://www.cnbeta.com/articles/172346.htm
新闻来源:oschina
最近一个叫Gary Bernhardt的程序员在CodeMash大会上的演讲的视频被人们炒的火热。在演讲中,他以Ruby和Javascript语言中一些很明显的很荒 唐的语言特征为乐子,逗的大家满堂欢笑。下面就是这个只有几分钟的视频,我把它加上了简单的字幕,奉献给大家。
Tags: wat, ruby, javascript
Misc | 评论:0
| 阅读:18199
Submitted by gouki on 2011, November 22, 10:03 PM
这也太夸张了吧。。。。用javascript实现jvm来运行java???
看到这个新闻我真的震精了,javascript什么时候也变得这么牛了?也就是说我们在javascript上都看轻了很多。
上原新闻:
Java不同于一般的编译语言和解释语言。它首先将源代码编译成字节码,然后依赖各种不同平台上的虚拟机来解释执行字节码,从而实现了“一次编译、到处执行”的跨平台特性。借助JavaScript引擎性能提升的东风,程序员Artur Ventura在JavaScript中实现了JVM虚拟机大部分标准,在Github上发布了BicaVM的源代码。
原文来自:http://developers.solidot.org/article.pl?sid=11/11/22/1129220&from=rss
真的很惊讶,原来javascript可以这样牛。
Tags: javascript, jvm, java
Javascript | 评论:2
| 阅读:18647
Submitted by gouki on 2011, November 16, 10:12 PM
今天在为ipad上的一个图片加上点击效果,在safari浏览器里一切正常,但到了ipad上,点击效果就死活出不来。
折腾了很久我才发现,我原来的触发的一个效果是写在a标签上的,也就是说,它是一个链接,然后onclick效果就起作用了。
于是我CreateElement了一个a,为它加上了onclick效果,果然,起作用了。。
------------
事实上很多人都和我说,div是有onclick事件的,嗯,我用Safari也测试确实有,但就是在ipad上无法实现。好吧。我承认我烂,可能是。。。。
可是我都一一在代码中测试了。
附上我那恶心至极的代码 (这是其中的一段,纯备份了):
JavaScript代码
- function ee(elem,popLayer) {
- var e = document.createElement("a"),scb=popLayer[0].querySelector('.showCaptionBody');
- e.setAttribute("href", "###");
- e.style.cursor = "pointer";
- e.style.position = "absolute";
- e.style.zIndex = 9;
- e.style.display = "block";
- e.style.right = "3px";
- e.style.bottom = "3px";
- e.style.width = "16px";
- e.style.height = "16px";
- e.style.backgroundImage = "url(data:image/gif;base64,R0lGODlhEAAQAIAAAMzMzP///yH5BAAHAP8ALAAAAAAQABAAAAIahI+py+0RHILy0Aoug7zH5HnPV2mSOWLqihUAOw==)";
- e.onclick = function() {
- var s = document.createElement("img");
- s.src = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAABx0RVh0U29mdHdhcmUAQWRvYmUgRmlyZXdvcmtzIENTNXG14zYAAAElSURBVEiJ1ZZNioQwEIVfhiYXqtmIIIokJxaRuEgOYM7hCdxas2gMbWKrDJ1FF9SmKr7PpJ4/gpmRMx4AIISYcogz8+9PDuHXeERE+oSoEMIfAtZ1/YT+LuId5AXk2MFuyOu67lJKiaIokvqWRVFASpnU3wKYeZdEBO89yrJMemVZwnsPIkp6iEUBTACmZVk4TiJiAExEp7XX3PSY+XoGzjnUdQ3vPaqqAoBw5865y7ndcpG1Fk3TwPunvYkI1tpbrvu3i+6uvQVQSoVjAZ5H1LYtxnG8BJy6iJl34sYYGGOCu5RSh9e8BcR+1loH8WEYQn0YhgDRWt9/DuKFm3jf90mv7/sAOQOczmCe58P6Fl3XnfYTwFe+7LIDBDN/9zdZ5P5t+QPZ7357iXsw1QAAAABJRU5ErkJggg==";
- scb.innerHTML = elem.innerHTML.split("\n").join("<br />");
- scb.removeChild(scb.querySelector("a"));
- scb.appendChild(s);
- popLayer[0].style.display="block";
- popLayer[0].querySelectorAll(".closeShow")[0].onclick = function(){
- popLayer[0].style.display="none";
- }
- };
- elem.appendChild(e);
- delete e;
- }
阿强说,是因为div没有宽度和高度,我说是100%,他说100%的话就是0。
好吧,我不是前端,我开始的时候没明白,但我没有时间来处理,我也没有空设定固定宽度,因为要考虑横竖屏。。所以先用临时方法替代了。
Tags: ipad, safari, javascript, onclick
Javascript | 评论:0
| 阅读:25312
Submitted by gouki on 2011, September 24, 3:33 AM
最近在做ipad上的网页处理的时候,经常需要切换横竖屏。于是找了一下资料,写了一个简单的判断:
function check(){
var s,screen = (window.innerWidth > window.innerHeight) ? "portrait" :"landscape";
if(s!=screen){
s=screen;
alert(s);
}
}
然后在document.addEventListener("DOMContentLoaded",function(){
//在这里加入
window.addEventListener("orientaionchange",check,false);
//然后就是很重要的一句:
setInterval(check,300);
})
为什么要用setInterval,就是因为每一次切换都要迅速判断,因此不得不用setInterval,否则第一次判断后就不会再处理了。。
Tags: javascript, ipad
Javascript | 评论:0
| 阅读:22376
Submitted by gouki on 2011, August 13, 12:41 AM
这是一篇来自苹果官方的教程,原来我也没想到过,居然可以用JS来调用Object-C中的东东。其实想想,这应该是可以,要知道,象maxthon这些浏览器,可就是早就能够调用他们的核心组件了,当然,也是用JS的。firefox也是类似。。。所以Safari应该也是可以支持的。
官方文章地址是:http://developer.apple.com/library/mac/#documentation/AppleApplications/Conceptual/SafariJSProgTopics/WebKitJavaScript.html
看看他们是怎么写的,
Important: This is a preliminary document. Although it has been reviewed for technical accuracy, it is not final. Apple is supplying this information to help you adopt the technologies and programming interfaces described herein. This information is subject to change, and software implemented according to this document should be vetted against final documentation. For information about updates to this and other developer documentation, you can check the ADC Reference Library Revision List. To receive notification of documentation updates, you can sign up for a free Apple Developer Connection Online membership and receive the bi-weekly ADC News e-mail newsletter. See http://developer.apple.com/products/for more details about ADC membership.)
还有。。。
Who Should Read This Document?
This document is designed for a number of different audiences:
-
If you are a web content developer—developing web sites and embedded JavaScript applications—you should read about Safari’s JavaScript support and how scripts operate within WebKit-based applications.
-
If you are a Cocoa and WebKit developer, you should read about how to integrate JavaScript into your WebKit views and how to enhance your user experience in doing so.
-
If you are a Dashboard developer, you should read about integrating JavaScript into your widgets to provide a better user experience and more advanced features to your users.
Organization of This Document
The topic contains the following articles:
See Also
-
Safari HTML Reference provides descriptions of HTML tags, attributes, and other markup.
-
Safari CSS Reference provides descriptions of CSS properties and constants.
-
Safari Web Content Guide provides information about designing web content for iPhone.
-
Dashboard Programming Topics provides information on the technologies available to you when creating a Dashboard widget. Additional Dashboard documents and sample code can be found in the Reference Library > Apple Applications > Dashboard.
-
Apple JavaScript Coding Guidelines provides general tips about the JavaScript programming language.
-
The Reference Library > Apple Applications > Safari section of the ADC Reference Library provides useful information on WebKit, the technology that provides Apple’s JavaScript runtime.
果然还是官方的资料最多,NND,平时搜点资料都搜不到,还是官方给的方案最多啊。
Tags: javascript, object-c, dom, webkit
苹果相关 | 评论:0
| 阅读:17692