반응형


function IE_Ver()

{

    if(navigator.appName.match(/Explorer/i))

    {

        return navigator.appVersion.match(/MSIE \d+.\d+/)[0].split(" ")[1];

    }

    else return 0;

}


function getInternetExplorerVersion() {

var rv = -1;

if (navigator.appName == 'Microsoft Internet Explorer') {

var ua = navigator.userAgent;

var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");

if (re.exec(ua) != null)

rv = parseFloat(RegExp.$1);

}

return rv;


위 두가지가 있다. 비슷비슷한놈이다.

위의 놈은 익스버전을 6.0,7.0과같은 형태로 반환하고 익스가 아닌브라우저는 0로 반환한다.

아랫놈은 익스버전을 6,7,8과 같은 형태로 반환하고 익스가 아닌 브라우저는 -1로 반환한다.

반응형

RadioButton을 2.0에서 서버컨트롤로 사용했다. <asp:DropDownList>의 선택값이 변할때 마다 RadioButton의 text값이 변하도록 

해야했으나 문제는 <asp:DropDownList>이 MasterPage상에 있어서 종속된 페이지에서 이를 서버코드로 제어할 수 없는 문제가 

있었던 것이다.


1.dropdownlist를 선택할때마다 radiobutton의 text를 변경

2.dropdownlist는 마스터페이지에 radiobutton은 종속페이지에 위치


이런 제약조건때문에 서버페이지에서 종속페이지의 컨트롤을 직접 제어할 수도 없는 난점때문에 자바스크립트로 해결하기로 했다.


$(document).ready(function(){

$('#dropdownlist').live('change',function(){

   var _chkcode = $('#dropdownlist_ClientID option:selected').val();

  var tags = document.getElementsByTagName('label');

  for(var i = 0; i < tags.length; i++){

if(tags[i].getAttribute('for') == 'RadioButton_ClientID'){

if(_chkcode == 'Code01'){

   tags[i].innerHTML = '텍스트1';

}

else if(_chkcode == 'Code02'){

   tags[i].innerHTML = '텍스트2';

}

}

}

});

});;


위와같은 방법으로 해결했다. 

<asp:RadioButton>은 html로 변환될경우 <input id='clientID' type='radio' value='serverID'/><label for='clientID'>텍스트</label> 로 

변환된다. 결국 Radio버튼의 text값은 <label for='clientID'의 값을 변경해야 하는 것이다. 그런데 <label은 id가 없기때문에

var tags = document.getElementsByTagName('label'); 이런식으로 label개체들을 for로 처리하여 해결한다.

tags[i].getAttribute('for') == 'RadioButton_ClientID' 이부분이 내가 원하는 label개체를 선별할 수 있도록 해준다. 


나머지는 일사천리~

반응형
먼저 부모창에 function test(){}이라는 함수가 있다고 가정한다.

1)팝업창일경우
opener.test();
2)iframe일경우 
parent.test(); 
와 같이 호출하면 된다. (무지쉽지?) 
3) 부모창에서 iframe내 함수접근
   var ifr = document.getElementById('iframeID');
    ifr.contentWindow.function_name();
부모창에서 'iframeID'이라는 iFrame에 지정된 페이지의 function_name()함수에 접근하는 방법이다.

4) <a href='www.url.com' target='_parent'>link</a>으로 지정해도 됨. 물론 자바스크립트를 제어하는 것은 아니라서
     parent.location.href='www.url.com';과 동일한 효과만 볼수 있음. 페이지 이동에 국한하여 사용할 수 있는 태그이다.
     기초적이고 간단한 것인데 종종 잊어먹곤 하니 유의할 것.


반응형
function get_QueryString(name) {
    name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
    var regexS = "[\\?&]" + name + "=([^&#]*)";
    var regex = new RegExp(regexS);
    var results = regex.exec(window.location.href);
    if (results == null)
        return "";
    else
        return decodeURIComponent(results[1].replace(/\+/g, " "));
}
 
반응형
_Val의 값중에 '<BR>'의 값을 개행문자로 변환할때 유용한 방법이다.

_Val = _Val.split("<BR>").join('\r\n');

출처 : http://blog.naver.com/troopa102?Redirect=Log&logNo=120054695785 
반응형
document.oncontextmenu=new Function('return false');  
document.ondragstart=new Function('return false');    
document.onselectstart=new Function('return false');

 
반응형
        var kcode = window.event.keyCode;

if((kcode>= 96) && (kcode <= 105))
{
window.event.returnValue = true;
return;
}
if(((kcode> 31) && (kcode < 45)) || (kcode > 57) ) {
window.event.returnValue = false;
return;
}

----------------------------------------------------------
인터넷에 돌아다니는 온갖 예제를 긁어갔다가 쓴맛만 봤다.
숫자는 되더라도 키보드오른쪽의 키패드는 인식돼지 않던가... 백스페이스 혹은 딜리트키가 안먹던가.
기타등등 ㅡ,.ㅡ;;; 그래서 그냥 기본소스 참조해서 새로만들었다.
백스페이스 딜리트 키보드오른쪽 숫자 영문한글 입력불가 되도록 만들었다.
기존참조했던 스크립트는 
if(((kcode> 31) && (kcode < 45)) || (kcode > 57) ) {
여기부터이고 그 상단의 if((kcode>= 96) && (kcode <= 105))는 키보드오른쪽 숫자입력을 위한부분이다.

반응형
        var f = document.createElement("form");
f.setAttribute("method","post");
f.setAttribute("target","iFrameName");
f.setAttribute("action","target.htm");
document.body.appendChild(f);

var i = new Array();
i[0] = document.createElement("input");
i[0].setAttribute("type","hidden");
i[0].setAttribute("name","name01");
i[0].setAttribute("value","value01");
i[1] = document.createElement("input");
i[1].setAttribute("type","hidden");
i[1].setAttribute("name","name02");
i[1].setAttribute("value","value02");

var cboOBJ = getID("cboOBJ");
i[2] = document.createElement("input");
i[2].setAttribute("type","hidden");
i[2].setAttribute("name","name03");
i[2].setAttribute("value",cboOBJ.selectedIndex);

f.appendChild(i[0]);
f.appendChild(i[1]);
f.appendChild(i[2]);
f.submit();
//=============================
문서내의 아이프레임(iFrameName)에 POST로 변수전달하는 방법이다.
target.htm을 타겟으로 post로 전달된 변수된다.
i[0]는 "name01" 에 "value01" 의 값을 가지고 //i[1]동일
i[2]는 cboOBJ라는 콤보박스의 선택된 인덱스값을 전달한다.

※ 위방법은 크롬플러스에서 동작한다. ie에서는 iframe이 아닌 새창으로 타겟을 띄운다.
반응형
window.onload = function(){
    FunctionName();
}

반응형
문자열 Replace하는 방법

var txtObj   = document.getElementById("txtObj");  
txtObj.value.repalce("\n","<br>");

개행문자를 <br>로 바꿔준다.
그러나 repalce("\n","<br>");로는 문자열의 첫개행문자만 변경하고 나머지는 변경되지 않음으로
옵션을 추가해준다.

txtObj.value.repalce(/\n/g,"<br>");
이렇게 하면 문자열의 모든 개행문자가 <br>로 대치된다.
참고로 /\n/g에서 g가 옵션이다.
g : 모든 문자열에서 검색
i : 대소문자구분안함
m : 여러줄 검색
옵션은 위와 같다. 사용법은 /\n/gi 와같은 방식으로 사용하면 된다.

+ Recent posts