반응형

다음과 같이 페이지를 벗어나기 전에, ‘수정사항이 있으니 다시 한번 확인해보세요’라는 메시지를 구현하는 방법에 대한 정리입니다.

Javascript의 window.onBeforeUnload Event를 이용한 기능입니다.

실행시점

window.onBeforeUnload Event는 Window개체가 Unload되기 전에 실행됩니다. 정확하게 다음과 같은 시점이 있을 수 있습니다. 다만 IE 7, 8에서는 버그로 인해 다르게 동작하는 경우도 있으므로 참고가 필요합니다.

  1. 창이나 탭을 닫을 때
  2. 새로고침, 앞, 뒤로 이동버튼 클릭 시
  3. location.href 변경
  4. Form Submit 발생 시
  5. A Tag 클릭 시
    • HREF에 URL을 지정한 경우: 발생
    • HREF에 #을 지정한 경우: 발생 안함
    • HREF에 javascript:void(0)을 지정한 경우: 발생 안함
      (IE7, 8에서는 onbefureunload이벤트가 발생하는 오류가 존재합니다.)
  6. Iframe 내부에서 로드된 경우 Iframe의 Src가 변경될 경우

구현방법

01 //onBeforeUnload 이벤트 지정
02 $(window).bind('beforeunload', function()
03 {
04     //페이지 변경이 있었는지 체크..
05     var isChanged = ....;
06  
07     //출력할 내용을 Return 해주면 확인 창이 뜨게 됩니다.
08     if(isChanged)
09         return '변경된 사항이 있습니다. 페이지에서 나가시겠습니까?';<br>
10     //확인 창을 띄우지 않으려면 아무 내용도 Return 하지 마세요!! (Null조차도)
11 };
12  
13 //Form Submit 등 onBeforeUnload Event가 발생하길 원하지 않는 경우, 이벤트 해제
14 $('form').submit(function()
15 {
16     $(window).unbind('beforeunload');
17 });

기타 확인사항

Firefox에서는 다음 그림과 같이, 지정한 안내텍스트가 출력되지 않는 버그가 있습니다. 곧 수정될 것이라고 하지만, 현재 Version 27까지도 수정되지 않은 상태입니다.



출처: http://nsinc.tistory.com/101 [NakedStrength Inc.]

반응형
반응형
-webkit-tap-highlight-color: rgba(0,0,0,0);

 

출처: https://css-tricks.com/snippets/css/remove-gray-highlight-when-tapping-links-in-mobile-safari/

반응형
반응형

input[type=number]::-webkit-outer-spin-button{-webkit-appearance: none;margin: 0;}
input[type=number]::-webkit-inner-spin-button{-webkit-appearance: none;margin: 0;}

반응형
반응형

<Connector> 가 한 개가 아니라는걸 간과해서 protocol 이 HTTP/1.1 인 <Connector> 에만 설정을 하는 것입니다. <Connector> 중에 protocol="HTTP/1.1" SSLEnabled="true" scheme="https" secure="true" clientAuth="false" sslProtocol="TLS" 등의 값이 포함된 다른 <Connector> 에도 URIEncoding 을 적어줘야 하고, mod_jk 을 통해서 처리하는 거라면 AJP/1.3 쪽 <Connector> 에서도 처리를 해야 합니다.

 

https 443 Connector에 URIEncoding="UTF-8" 추가 후 해결,

반응형
반응형

Just discovered how super simple it was to add some gz compression when for example providing JSON data from PHP.

All you need is regular output buffering with the ob_gzhandler as output callback.

// Fetch some data
$data = get_data();

// Turn on output buffering with the gzhandler
ob_start('ob_gzhandler');

// Output as normal
echo json_encode($data);

The cool thing is that it actually looks at what the browser accepts before doing anything.

Before ob_gzhandler() actually sends compressed data, it determines what type of content encoding the browser will accept (“gzip”, “deflate” or none at all) and will return its output accordingly. All browsers are supported since it’s up to the browser to send the correct header saying that it accepts compressed web pages.

Tried adding it for a text field with timezone auto-completing for example, and without this handler:

Content-Length    5517
Content-Type      application/json

With this handler:

Content-Encoding  gzip
Vary              Accept-Encoding
Content-Length    1775
Content-Type      application/json

Do like! 😆

반응형
반응형

 

 

ios app 을 웹 어플리케이션에서 킬때... 사파리에서는 안먹히는 것 해결

반응형
반응형

jquery-ui 의 dialog close 버튼이 안보일때

bootstrap.min.js 와 스크립트 충돌로 인한것으로 해당 스크립트를 우선순위를 바꾸거나 제외하면 정상적으로 보인다.

반응형
반응형

var url_regex = /(http(s)?:\/\/([\w-]+\.)+[\w-]+(\/[\w-.\/?%&=]*)?)/gi;
var email_regex = /([a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+\.[a-zA-Z0-9._-]+)/gi;

 

var string = "도메인은 http://www.huzy.net/ 이고 이메일은 root@yjhoon.com 입니다.";

 

var url_result = string.match(url_regex);

=> ["http://www.huzy.net/"]

 

var email_result = string.match(email_regex);

=> [root@yjhoon.com"]

 

 

result 값은 둘다 배열로 리턴되서 나옴 .

반응형

+ Recent posts