반응형
jQuery에서 어떤게 먼제 실행되는지에 대해서 궁금한데.

$(document).ready 는 DOM 이 준비가 되면 바로 실행을 한다.

$(window).load 는 페이지 내의 모든 데이터(요소)가 다 준비가 되어야 실행한다.

그 차이를 알아채기는 쉽지 않겠지만. 그렇다고 한다.

그런데, 실제 경험상 그 차이는 크게 느낄수 없었다.

이 둘의 차이를 따지게 되는 상황에서 중요한 점은 페이지가 얼마나 빨리 Load 되느냐지
실행이 어느순간에 되는건 고려되지 않았기 때문이다.
이론에 대한 얘기이며, 실기에선 고려되지 않았었다는 사설.

그래도, $(document).ready를 쓰는 것이 일반적인 상황에서는 맞는거 같다.
이미지로 뭔가를 하려는게 아니라면.
이미지 요소로 뭔가를 하려 한다면, $(window).load 를 써야하지 않을까?
반응형

'프로그래밍 > Script' 카테고리의 다른 글

[javascript] Navigator  (0) 2012.04.30
node.js 외 js 관련  (0) 2012.03.26
HTML5 Web Workers  (0) 2012.02.21
20+ Must See Fresh and Useful jQuery Plugins from 2011  (0) 2011.12.09
5 Awesome Responsive jQuery Sliders and Image Galleries  (0) 2011.12.09
반응형
HTML5 Web Workers :
A web worker is a JavaScript running in the background, without affecting the performance of the page.
스크립트가 완료될 때까지 HTML 페이지에 스크립트를 실행하면 페이지가 응답된다.

Web Workers는 페이지의 성능에 영향을주지 않고 독립적으로 다른 스크립트의 백그라운드로 실행되는 자바 스크립트입니다. 당신이 원하는 건 뭐든지 할 계속할 수 있도록: Web Workers가 백그라운드에서 실행되는 동안 클릭, 셀렉팅, 기타등등을 합니다.

http://w3schools.com/html5/html5_webworkers.asp
반응형
반응형

20+ Must See Fresh and Useful jQuery Plugins from 2011

jQuery gives developers the chance to enrich websites with amazing elements without the need to write dozens of lines of code. This post presents advanced and cutting-edge jQuery plugins that will enhance your web designs tremendously.

Supersized 3.2 – Fullscreen Slideshow jQuery Plugin

Supersized 3.2 – Fullscreen Slideshow jQuery Plugin
Full screen background slideshow plugin for jQuery.

Expanding Fullscreen Grid Portfolio

Expanding Fullscreen Grid Portfolio
The main idea is to have a grid layout created with jQuery Masonry. View more expand the according item to fullscreen in order to show a longer description of the item and a representative fullscreen background image.

Quovolver

Quovolver
Quovolver is a simple extension for jQuery that takes a group of quotes and displays them on your page in an elegant way.

jQuery Spin Button Plugin: Smart Spin

jQuery Spin Button Plugin: Smart Spin
Smart spin is a jQuery spin button plugin that mimics the very common windows spin button control. Smart spin allows you to select a value between minimum and maximum values using either mouse or keyboard. You can also enter a value via keyboard.

FitText

FitText
FitText makes font-sizes flexible. Use this plugin on your fluid or responsive layout to achieve scalable headlines that fill the width of a parent element.

DropKick

DropKick
Creating custom dropdowns is usually a tedious process that requires a ton of extra setup time. Oftentimes lacking conveniences that native dropdowns have such as keyboard navigation. DropKick removes the tedium and lets you focus on making menu looks good.

HTML5 jQuery Music Player

HTML5 Music Player
Remember that awesome music player psd created by Orman Clark? Well here is the matching jQuery plugin.

Circular Content Carousel with jQuery

Circular Content Carousel with jQuery
A simple jQuery circular content carousel.

jQuery Image Gallery

jQuery Image Gallery Demo
Image Gallery with Lightbox effect and slideshow functionality for jQuery UI.

Overscroll

Overscroll
Overscroll is a jQuery plug-in that mimics the iphone/ipad scrolling experience in a browser.

jBar

jBar
jbar is a jQuery plugin that transforms an unordered list <ul> into a toolbar with dropdown menus.

leanModal

leanModal
Super simple modal window plugin that works with your CSS. Perfect for hidden page content. Flexible width & height, image free, supports multiple instances on one page. Great for login, sign up & alert panels, etc.

ImageLens – A jQuery plug-in for Lens Effect Image Zooming

ImageLens – A jQuery plug-in for Lens Effect Image Zooming
Use this jQuery plug-in to add lens style zooming effect to an image.

My QR Code

My QR Code
Generate QR code for mobile devices using Google Chart Api with jquery. By default, the plugin will generate the QR code for the URL of the page. You can also specify the text, encoding and size of the QR code.

Simple Overlay

Simple Overlay
A jQuery Plugin for easily adding lightweight, flexible overlays to your projects.

MobilyMap

MobilyMap
MobilyMap is a jQuery plugin (7KB) that can create a Google Maps-like, draggable interface from any image.

Snippet

Snippet
Snippet is a jQuery syntax highlighting plugin built on top of the SHJS script found on SourceForge. Snippet provides a quick and easy way of highlighting source code passages in HTML documents.

NETEYE Activity Indicator

NETEYE Activity Indicator
A jQuery plugin that renders a translucent activity indicator (spinner) using SVG or VML.

jLinkPreview

jLinkPreview
jLinkPreview is a plug-in for jQuery Library which simply allows you to see link’s preview image before you visit them by just hovering on it. Link Preview will appear by your cursor when you hover.

jRumble

jRumble
jRumble is a jQuery plugin that rumbles, vibrates, shakes, and rotates any element you choose. It’s great to use as a hover effect or a way to direct attention to an element.

Grid Navigation Effects with jQuery

Grid Navigation Effects with jQuery
jQuery plugin for achieving some neat grid navigation effects.
반응형
반응형

5 Awesome Responsive jQuery Sliders and Image Galleries

In responsive design all design components need to be able to adapt to the environment in which they are displayed and have to interact with. We create tables, navigation menus, videos and other design elements responsive including the image sliders.
In this post we present you 5 super awesome Responsive jQuery Sliders and Image Galleries which you can use in your next project.

FlexSlider

FlexSlider

FlexSlider was built to serve up the best responsive jQuery slider around. The plugin includes fade and slide animations, customizable options as well as all the navigation options you would expect in such a plugin — touch gestures inclusive!

Blueberry

Blueberry

Blueberry is an experimental opensource jQuery image slider plugin which has been written specifically to work with fluid/responsive web layouts.

Photo Swipe

Photo Swipe

PhotoSwipe is a free HTML/CSS/JavaScript based image gallery specifically targeting mobile devices. iPhone, iPad, Android, Blackberry 6 and Desktop all supported.

Responsive jQuery Slideshow

Responsive jQuery Slideshow

This example makes it possible to have fluid jQuery slideshow which scales responsively.

Dynamic-Carousel

Dynamic-Carousel

A carousel plugin built for responsive layouts.

If need some guidance for MB2-631 exams then get the latest 70-673 compiled by our certified experts to help you pass MB5-856 exam in first attempt of testking mcitp.

반응형
반응형
http://visualjquery.com/ - 기본적인 jQuery 내용
반응형
반응형

JavaScript에서의 location.href 와 location.replace 의 차이점


자바스크립트에서 페이지 이동 시킬때 location.href를 많이 사용하지만 location.replace 메세드도 종종 이용된다.
두가지 모두 같은 동작을 하는거 같지만 실제로는 아래와 같은 차이점이 있다.

location.href는 객체의 속성이며, loaction.replace()는 메서드(함수)로 작동된다.
href는 페이지를 이동하는 것이기 때문에 뒤로가기 버튼을 누른경우 이전 페이지로 이동이 가능하지만,
replace는 현재 페이지를 새로운 페이지로 덮어 씌우기 때문에 이전 페이지로 이동이 불가능하다.

href는 일반적인 페이지 이동시 이용을 하면 되고,
replace의 경우는 이전페이지로 접근이 필요없는경우 보안상 덮어씌우는 것도 괜찮을듯 하다.

location.href Method

Including the following script will immediately redirect visitors to the URL entered.

<script type="text/javascript">
     location.href='http://www.bloggingdeveloper.com';
</script>
 

location.replace Method

Including the following script will immediately redirect visitors to the URL entered.

<script type="text/javascript">
     location.replace('http://www.bloggingdeveloper.com/');
</script>

The difference between location.href and location.replace

The difference between location.href and location.replace is that the former creates a new history entry on the visitor's browser meaning that if they hit the back button, they can get in a 'redirection loop' which is usually undesirable and may have unwanted side effects.

반응형
반응형
사용자 정의 플러그인으로 jQeury 확장하기

jQuery를 사용하면 페이지에 특정코드 스타일을 사용하게 되는데, 엘리먼트를 확장 집합의
형태로 표현하고 jQuery 커맨드나 커맨드체인을 확장 집합에 사용하는 코드 스타일을 자주 쓰게 된다. 물론 자신만의 코드를 작성할 때는 마음대로 코드를 작성할 수 있다.

자신만의 코드를 패턴화하여 jQuery 확장으로 만들면 좋은 이유는 사이트 전체에 일관된 코드 스타일을 유지하는데 도움을 주고, 재사용이 가능하며, jQuery 가 제공하는 기반코드를 확용할 수 있다.

플러그인이 다른 jQuery 플러그인이나 자바스크립트 라이브러리와 충돌하지 않고 잘 동작하는지가 확실하게 보장되기 위해 알려진 일반적인 지침을 사용한다.

이름을 충돌하지 않도록 만드는 방법은
* 접두어로 jquery. 를 사용한다.
* 이어서 플러그인 이름을 적는다.
* .js 로 파일 이름을 끝맺는다.
예를 들어서 jquery.ngio.js

 그리고, jQuery 대신 $ 를 사용하는 편이 훨씬 편한데, 충돌을 피하기 위해 $ 대신 jQuery를
사용하는 것이다.  하지만 $ 쪽이 훨신 편리하기에 포기하고 싶지 않다.
그래서, $ 라는 매개변수를 정의한 함수에 jQuery를 전달하면  $는 함수 안에서 jQuery의 참조임이 보장된다.
(function($) {
//
//
//  여시에 플러그인을 정의한다.
//
})(jQuery);'

복잡한 매개변수 목록을 단순하게 만들기.
플러그인은 대부분 매개변수를 몇 개만 요구할 정도로 단순하다. 선택적인 매개변수가 생략되면 적절한 기본값이 제공되며,매개변수가 생략되면 매개변수의 순서에 내포된의미도 변경된다.

    function complex(p1,p2,p3,p4,p5){
이 함수는 매개변수가 5개인데, 이 중에 첫 매개변수를 제외한 모든 매개변수가 선택사항일 경우, 선택적인 매개변수가 너무 많다면 매개변수가 생략되었을 때 호출자의 의도를 합리적으로 추측하기가 어려워진다. 이 함수의 호출자가 마지막 매개변수만 생력했다면 마지막 선택적 인수를 null 값으로 확인할수 있기 때문에 문제되지 않지만,
but 호출자가 p5를 명시하고 p2~p4 까지는 기본값으로 지정하고 싶은 경우엔 호출자는 생략된 매개변수 부분에 생략표시를 하고 다음과 같이 작성해야 한다.
     complex(valueA, null, null, null, valueB);

위와 같은 경우 null 과 매개변수의 순서를 주의깊게 봐야하는 단점이 있다.
일반적으로 이러한 문제를 해결하는 데 선택사항의 해기(option hash)를 많이 사용한다.
 선택사항의 해시를 사용하면 선택적인 매개변수 정보를 이름/값 쌍 형식의 프로퍼티로
가지는 자바스크립트의 Object 인스턴스로 전달한다.
    complex( valueA, { p5:valueB } );
  또는
    comlplex( valueA, {
       p3 : valueC,
       p5 : valueD
    } );

위와 같은 방법을 사용하면 null을 사용하여 생략된 매개변수를 표시할 필요가 없고 매개변수의 개수를 세지 않아도 된다.
필수 매개변수 하나와 선택항목을 여섯 개 가진 복잡한 함수 예제를 다시 살펴보자
    complex(p1, options)
함수 내에서 $.extend() 유틸리티 함수를 사용해 기본값에 전달된 옵션을 합칠 수 있다.
    function comlex( p1, options ){
        var settings = $.extend({
            option1: defaultValue1 ,
           option2: defaultValue2 ,
           option3: defaultValue3 ,
           option4: defaultValue4 ,
           option5: defaultValue5 ,
           option6: defaultValue6 
         , options || { } );
         // 함수의 나머지 부분
    }
settings 변수는 페이지 개발자가 options 매개변수로 전달한 값과 기본값을 합친 값을 가진다. 주목할 점은 ||{}를 사용하여 options 객체가 null이거나 undefined 인지를 확인하고 있다는 것이다. 만약 options 변수가 false라면 (null과 undefined는 조건식에서 false이다) 빈 객체가 사용된다.

ex)
 $.say = function(what) { alert( 'I say ' + what ); }

jQuery.say = function(what) { alert( 'I say ' + what ); }

(function($) {
    $.say = function(what) { alert( 'I say ' + what ); }
}) (jQuery);

## 데이터를 조작하는 유틸 함수 만들기
고정폭으로 숫자 값을 표시하려면 숫자 값과 고정폭 필드(폭은 문자의 수로 정의)에 맞는 형식이 필요하다. 대개 이러함 형식은 값을 고정폭 필드에 우측 정렬시키고 값의 길이와 필드의 길이 차이를 조정하기 위해 채움 문자( fill character )로 앞 여백을 채운다.

함수 문법 : $.toFixedWidth
$.toFixedWidth( value, length, fill )
 : 매개변수 - value (Number) 형식화될 값
                   - length (Number) 결과 필드의 길이
                   - fill (String) 앞 단의 값을 채울 채움 문자, 생략하면 0을 사용한다.

(function($){
    $.toFixedWidth = function( value, length, fill ){
        var result = value.toString();
        if( !fill ) fill = 0;
        var padding = length - result.length;
        if( padding < 0 ){
            result = result.substr(-padding);
        }
        else{
            for(var n = 0; n < padding; n++)
                result = fill + result;
        }
        return result;
    };
})(jQuery);






반응형
반응형

jQuery Alert Dialogs (Alert, Confirm, & Prompt Replacements)

http://abeautifulsite.net/blog/2008/12/jquery-alert-dialogs/

Overview

This jQuery plugin aims to replace the basic functionality provided by the standard JavaScript alert(), confirm(), and prompt() functions. What’s the benefit of using custom methods? Well, a few good reasons, really.

Implementation

Include the following in the <head> section of your HTML document(s):

<!-- Dependencies -->
<script src="/path/to/jquery.js" type="text/javascript"></script>
<script src="/path/to/jquery.ui.draggable.js" type="text/javascript"></script>
<!-- Core files -->
<script src="/path/to/jquery.alerts.js" type="text/javascript"></script>
<link href="/path/to/jquery.alerts.css" rel="stylesheet" type="text/css" media="screen" />

Make sure you update the path to the respective files. If you are already using the jQuery UI Draggable plugin (including the UI core), simply omit the link to jquery.ui.draggable.js.

For IE to display the dialogs properly, you’ll also need to make sure that you’re using Standards Mode.  Just add the appropriate DTD at the very top of your page:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

Usage

This plugin utilizes the $.alerts namespace, but there are three built-in shortcut functions that make implementation easier:

  • jAlert(message, [title, callback])
  • jConfirm(message, [title, callback])
  • jPrompt(message, [value, title, callback])

Unlike their native JavaScript counterparts, you can use HTML in the message parameter. To specify a newline, you can use either \n or <br />.

These methods do not return the same values as confirm() and prompt(). You must access the resulting values using a callback function. (See the demo for more details.)

Compatibility

This plugin requires jQuery 1.2.6 or above and has been tested to work in the following browsers:

  • Internet Explorer 6 & 7
  • Firefox 2 & 3
  • Safari 3
  • Chrome
  • Opera 9

Known Issues

  • ENTER and ESC keys (to accept/cancel) don’t work in WebKit browsers
  • The draggable plugin doesn’t currently work in Opera
  • IE6 acts a bit differently as position: fixed isn’t supported.
반응형

+ Recent posts