Dragon in the sky

whatever happened , go ahead! Happy life of big pig and its dog.
posts - 98, comments - 11, trackbacks - 0, articles - 1
  博客园 :: 首页 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理

公告

2010年1月4日

1、    JavaScript包括哪些数据类型?

我回答的是有两种:基本类型和对象,其中基本类型包括数字、字符串、布尔和null;对象(类似对象),包括数组、函数、内置对象、自定义对象。不过按理说字符串也有些对象的特点。

我这个回答是参考的JavaScript权威指南的,有些小问题,第一类中缺少了undefined。

搜索了下,网上还有几种回答:

第一种:共九种类型:1.未定义(undefined) 2.空(null) 3.布尔(boolean) 4.字符串(string) 5.数字(number)6.对象(object) 7.引用(reference) 8.列表(list) 9.完成(completion)。reference,list,completion这3种类型是做为JavaScript运行时中间结果的数据类型 在代码中不能使用。

最后我确实没见过。

第二种:javascript中包含6种数据类型:undefined、null、string、number、boolean和object。其中,前5种是原始数据类型,object是对象类型。object类型中包括Object、Function、String、Number、Boolean、Array、Regexp、Date、Globel、Math、Error,以及宿主环境提供的object类型。

除去reference,list,completion不同外,这几个回答其实大同小异。

2、<img>元素的alt和title有什么异同?

这个我前几天正好看到了一篇这样的文章。这两个属性是有些重复了。在不同浏览器里面表现有些不同。在alt和title同时设置的时候,alt作为图片的替代文字出现,title是图片的解释文字。

刚刚小小的实验了一把,在没有title的时候,alt会作为图片的解释,但是Firefox好像不这样做。完全测试的话要分图片存不存在、只有title、只有alt,2*2*2,8种情况,真复杂啊。

3、    border-color-left、marin-left、-moz-viewport改写成JavaScript格式

这个就是-后字符换大写,没什么问题。第三个-moz的真不敢确定。(未完待续)

ps:刚接到了百度面试的电话,等了好久,以为没希望了呢,小小高兴一下吧。不过我也没有多大的优势,不管是技术方面还是经验方面只有劣势没有优势,只是rp还行(窃喜一下)。笔试通过的有些侥幸,去百度的希望不大。

继续:刚才试验了一个-moz-border-radius确实是写成MozBorderRadius。

4、 编写一个JavaScript函数,实时显示当前时间,格式“年-月-日 时:分:秒”

主要是用到了各种时间函数,setInterval(funtionName,Time),firstChild.nodeValue。

setInterval函数名我好像写错了。我写的是最普通最简单的函数,每隔一秒钟重新获取时间。有很多值得优化的地方。程序写的不好看,就不献丑了。

5、 用css、html编写一个两列布局的网页,要求右侧宽度为200px,左侧自动扩展。

我主要的想法是右侧绝对定位,左框右边距200px,正好空出了右侧的位置。

我写的CSS如下:

#right{
  position:absolute;
  right:0;
  width:200px;
}
#left{
  marin-right:200px;
}

另一种方法(试验有效):

#right{
  float:right;
  width:200px;
}
#left{
  marin-right:200px;
}

HTML代码中#right必须写在#left前面

<body>
  <div id=”right”>…</div>
  <div id=”left”>…</div>
</body>

这好像是道经典面试题,在某次面试的时候,就被问过这个问题。还有一道经典的问题是如何使固定宽度的div在页面居中。

6、 使用JavaScript深度克隆一个对象?

JavaScript的对象赋值var anObj = anOtherObj 用的是传址方式,不能用于复制对象。

用对象原型写通用性更强些,但是当时对prototype没有十分的把握,只写了个克隆函数。刚刚查了下,果然有猫腻,下面是实现代码:

function Object.prototype.cloneObj()
{
  function NEWOBJECT(){};
  NEWOBJECT. prototype = this;
  var anObj = new NEWOBJECT();
  for ( var ele in anObj )
  {
   if ( typeof anObj[ele] == “object” ) return anObj[ele]. cloneObj();
  }
  return anObj;
}

7.Linux题目:批量删除当前目录下后缀名为.c的文件,如a.c、b.c

我的回答是rm *.c

幸亏我还有点点linux基础,当然更得归功于考前复习了几个常用linux命令。

附加题是Flash的AS题,大概是比较AS2.0和AS3.0在面向对象方面的异同吧。我都有好久好久没有接触过AS了,这题我没答。

From : http://www.webjx.com/javascript/jsajax-17997.html

posted @ 2010-01-04 15:35 龙泰 阅读(681) 评论(1) 编辑

Using jQuery with ASP.NET - A Beginner's Guide

Did you hear about jQuery.. NO...? It’s fantastic!! Well if you have been hearing those words more too often from your colleagues but haven’t had the chance to explore jQuery yet, then here’s this beginner guide for you to get started with jQuery and ASP.NET.

Update: I have written an EBook on using jQuery with ASP.NET Controls. It's called "51 Tips, Tricks and Recipes with jQuery and ASP.NET Controls".

Ok, the million dollar question - What is jQuery anyways?

jQuery is a fast, lightweight JavaScript library that is CSS3 compliant and supports many browsers. The jQuery framework is extensible and very nicely handles DOM manipulations, CSS, AJAX, Events and Animations.

What is the difference between JavaScript and jQuery?

JavaScript is a language whereas jQuery is a library written using JavaScript.

Where can I download jQuery?

The latest version of jQuery as of this writing is jQuery 1.2.6 and can be downloaded from here. [Update] An updated version of jQuery 1.3.2 has been released. jQuery 1.3.2 and jQuery 1.3.2 Visual Studio 2008 Autocomplete documentation. So whereever you see 1.2.6 mentioned in the rest of this article, just replace it with 1.3.2.

What has Microsoft got to do with jQuery?

In ScottGu’s blog, there was an announcement made a few weeks ago that Microsoft will be partnering with the jQuery team and shipping jQuery with Visual Studio in future. Also, jQuery intellisense annotation support will be available as a free web-download. Barely a few weeks after the announcement, Microsoft during the PDC event (held in the last week of October), announced that Visual Studio 2008 now supports jQuery Intellisense through an additional file available from jQuery. This file can be downloaded from here. For those interested, the release notes can be found here 1.2.6 (Release Notes).

A few days ago, Microsoft also released a VS2008 SP1 Hotfix to support all JavaScript files including jQuery intellisense for Visual Studio 2008. Note that this hotfix works only if you have VS 2008 with SP1 or Visual Web Developer Express Edition with SP1. You can download the Hotfix from here (Downloads tab).

Checking out jQuery Intellisense in Visual Studio 2008 with SP1

Assuming you have installed the hotfix , downloaded the jQuery library and the jQuery VS 2008 IntelliSense documentation, follow these steps to move ahead.

Open Visual Studio 2008 > File > New > Website > Choose ‘ASP.NET 3.5 website’ from the templates > Choose your language (C# or VB) > Enter the location > Ok. In the Solution Explorer, right click your project > New Folder > rename the folder as ‘Scripts’.

Right click the Scripts folder > Add Existing Item > Browse to the path where you downloaded the jQuery library (jquery-1.2.6.js) and the intellisense documentation (jquery-1.2.6-vsdoc.js) > Select the files and click Add. The structure will look similar to the following:

jQuery Structure

Now drag and drop the jquery-1.2.6.js file from the Solution Explorer on to your page to create a reference as shown below

jQueryRef

Note: Since you have applied the hotfix, you do not have to manually add a reference to the jquery-1.2.6-vsdoc.js file in your page. Once the reference to the runtime library has been added, Visual Studio automatically searches for the ‘vsdoc’ file and loads it. You just need to keep both the runtime library and the documentation file next to each other.

To test intellisense, add a <script> block and key in ‘$(‘. You will get an intellisense similar to the one shown below:

jQuery Intellisense

Show me some examples

This article would be incomplete without examples. So let us quickly see some.

Example 1 – Display an alert on asp:Button click using jQuery

 

From : http://www.dotnetcurry.com/ShowArticle.aspx?ID=231&AspxAutoDetectCookieSupport=1

posted @ 2010-01-04 15:18 龙泰 阅读(150) 评论(0) 编辑

jQuery是我最近发现的一个新工具。jQuery开发团队形容jQuery是“一个快捷、简练的JavaScript库,它可以简化HTML文档检查、事件处理、动画执行、并给你的Web页面增加AJAX交互。”
jQuery初步
你可以免费下载jQuery 的最新版本。它由一个明确定义的脚本文件构成,因此你可以随意研究它的源代码。下载JavaScript文件后,你就可以把它放在Web服务器中准备使用。你可以用HTML SCRIPT元素把jQuery库加载到任何Web页面中。src属性应利用文件在服务器中的真实路径。
<script type="text/javascript"
src="jquery-latest.js"></script>
下载文件后,以下的一些任务会对你使用jQuery有所帮助。
编码基础
以下是使用jQuery编码时用到的一些指针:
    * jQuery代码块前为美元符号($)。
    * 美元符号后是一个左圆括号。
    * 括号内是你要jQuery查找的内容,如它应使用哪个元素。
    * 特定对象事件后为右圆括号。
    * 你可以用指定的事件定义所发生的操作。方法/事件后的括号内是一个说明发生事件时会出现什么操作的函数。 
在举例说明之前,我想介绍jQuery库的一个最有益的基础元素。JQuery利用的一切功能全都位于HTML DOM中,因此在你使用jQuery的特性之前,你必须加载这个文档。你可以用这个文档的ready事件完成上述操作,如下面的jQuery代码段所示:
$(document).ready(function() {
// Your code goes here
});
上面的简单jQuery代码允许你在文档完成加载后执行代码。列表A是它的一个应用实例,它对页面上的所有标题元素应用一个CSS类。
<html><head>
<title>Test</title>
<script type="text/javascript" src="jquery-latest.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$('h1').addClass("testclass");});
</script>
<style type="text/css" media="all">
.testclass { background: yellow; font-size: 20pt; }
</style>
</head>
<body>
<h1>Test</h1>
<p>test</p>
<h1>Test2</h1>
<p>test2</p>
</body></html>
这段代码中包含以下元素:
    * $(document).ready(function(){——在页面完全加载后,告诉页面执行(函数主体内)的代码。
    * $('h1').addClass("testclass");});——定位页面上的所有HTML H1元素。addClass方法将所有的testclass CSS类分配给H1元素。这个类设定一个黄色背景色,因此所有标题都为黄色背景。

http://www.qhwins.com/ShowNews/?16-200811171518414794.html

posted @ 2010-01-04 15:12 龙泰 阅读(77) 评论(0) 编辑