'Windows/JAVASCRIPT'에 해당되는 글 13건

문자 체크

Windows/JAVASCRIPT 2016. 12. 21. 12:43
<html>
<script>
var chkWord = new Array( 'select', 'delete', 'update');
function chk(str)
{
for(i=0;i<chkWord.length;i++)
{
var text = str;
var findStr = chkWord[i];
if (text.indexOf(findStr) != -1) 
                        {
alert('있다');
break;
}
else 
                        {
alert('없다');
}
}
}
chk('deletesafasdfa');
</script>

<body >
</body>
</html>


Posted by 아로스

var jScript = document.createElement("script"); 

jScript.src = "경로/파일명.js"; 

document.head.appendChild(jScript); 

Posted by 아로스
  • 인터넷익스플로러에서만 동작하는 input text 박스 숫자만 입력받기
<input type="text" style="ime-mode:disabled;" onKeyPress="if ((event.keyCode> 47) && (event.keyCode < 57)){event.returnValue=true;} else { event.returnValue=false;}>

숫자만 입력받기 이다. 하지만 이렇게 하면 인터넷 익스플로러에서는 동작을 하지만 파이어폭스에서는 동작하지 않는다.

  • firefox, 인터넷익스플로러 둘다에서 동작하는 input text 박스 숫자만 입력받기

<input type="text" style="ime-mode:disabled;" onKeyPress="return numbersonly(event, false)">


function numbersonly(e, decimal) {
    var key;
    var keychar;

    if (window.event) {
        key = window.event.keyCode;
    } else if (e) {
        key = e.which;
    } else {
        return true;
    }
    keychar = String.fromCharCode(key);

    if ((key == null) || (key == 0) || (key == 8) || (key == 9) || (key == 13)
            || (key == 27)) {
        return true;
    } else if ((("0123456789").indexOf(keychar) > -1)) {
        return true;
    } else if (decimal && (keychar == ".")) {
        return true;
    } else
        return false;
}


Posted by 아로스

<html>
<head>
<title>커뮤니티</title>
<script language="javascript">
<!--


/**
 * 기본생성자
 * @param obj:Player 객체
 */
function WindowMediaPlayer(obj,url,autostart)
{
 this.player = obj;
    this.player.url = url;
    this.player.settings.autoStart = autostart;
    this.player.settings.rate = 1;
    if (autostart) player_play();
}

/**
 * 미디어를 재생한다.
 * @param mldom:mldom 객체
 * @param autostart:자동 시작 여부
 */
function player_play()
{
    if (this.player.url == '') return;
    this.player.controls.play();
}

/**
 * 미디어를 정지한다.
 */
function player_stop()
{
    if (this.player.url == '') return;
    this.player.controls.stop();
}

/**
 * 미디어를 일시정지한다.
 */
function player_pause()
{
    if (this.player.url == '') return;
    this.player.controls.pause();
}

/**
 * 미디어를 빨리감기한다.
 */
function player_fastForward()
{
    this.player.controls.fastForward();
}

/**
 * 미디어를 되감기한다.
 */
function player_fastReverse()
{
    this.player.controls.fastReverse();
}

/**
 * 미디어의 재생 속도를 조정한다.
 * @param no:재생 속도
 */
function player_setRate(no)
{
    this.player.settings.rate = no;
    this.player.controls.play();
}

/**
 * 미디어의 소리를 증가한다.
 * @param no:재생 속도
 */
function player_addVolume(no)
{
    this.player.settings.volume += no;
}

/**
 * 미디어의 소리를 조정한다.
 * @param no:소리크기(0~100)
 */
function player_setVolume(no)
{
    this.player.settings.volume = no;
}

/**
 * 미디어의 소리를 없앤다.
 * @param v:음소거 여부(boolean)
 */
function player_mute(v)
{
    this.player.settings.mute = v;
}

/**
 * 미디어의 크기를 조정한다.
 * @param no:미디어 크기(0~4). 0:정상,1:절반,2:두배,3:전체화면
 */
function player_resize(no)
{
    if (this.player.url == '') return;
    var width = this.player.currentMedia.imageSourceWidth;
    var height = this.player.currentMedia.imageSourceHeight;
    var width_ctrl = 5;
    var height_ctrl = 75;

    if (this.player.uiMode == 'invisible') {
        width_ctrl = 0;
        height_ctrl = 0;
    } else if (this.player.uiMode == 'none') {
        width_ctrl = 0;
        height_ctrl = 0;
    } else if (this.player.uiMode == 'mini') {
        width_ctrl = 5;
        height_ctrl = 75;
    } else if (this.player.uiMode == 'full') {
        width_ctrl = 5;
        height_ctrl = 75;
    }

    this.player.stretchToFit = 'true';

    switch (no) {
        case 0:
         this.player.width = width + width_ctrl;
         this.player.height = height + height_ctrl;
         break;
        case 1:
         this.player.width = 0.5 * width + width_ctrl;
         this.player.height = 0.5 * height + height_ctrl;
         break;
        case 2:
         this.player.width = 2 * width + width_ctrl;
         this.player.height = 2 * height + height_ctrl;
         break;
        case 3:
         if (this.player.playState == 3) this.player.fullScreen = 'true';
         break;
    }
}

/**
 * 미디어의 위치를 처음으로 옮긴다.
 */
function player_setPosStart()
{
    this.player.controls.currentPosition = 0;
}

/**
 * 미디어의 위치를 마지막으로 옮긴다.
 */
function player_setPosEnd()
{
    if (this.player.url == '') return;
    this.player.controls.currentPosition = this.player.currentMedia.duration;
}

/**
 * 미디어의 위치를 옮긴다
 * @param no:옮길 위치(단위 초)
 */
function player_setPos(no)
{
    this.player.controls.currentPosition = no;
}

/**
 * 미디어의 위치를 해당 프레임으로 옮긴다
 * @param no:옮길 위치(단위 프레임)
 */
function player_setPosFrame(no)
{
    if (this.player.url == '') return;

    var fps = this.player.network.encodedFrameRate;
    if (fps > 0)
        this.player.controls.currentPosition = no / fps;
   
}

/**
 * 미디어의 위치를 증가시킨다
 * @param no:옮길 위치(단위 초)
 */
function player_addPos(no)
{
    this.player.controls.currentPosition += no;
}

/**
 * 미디어의 위치를 해당 프레임만큼 증가시킨다
 * @param no:옮길 위치(단위 프레임)
 */
function player_addPosFrame(no)
{
    if (this.player.url == '') return;

    var fps = this.player.network.encodedFrameRate;
    if (fps > 0)
        this.player.controls.currentPosition += no / fps;
}

/**
 * 초기화
 */
function init_me()
{
 var url = "mms://mmc.daumcast.net/mmc/1/500/0902600000101h.wmv";
 var autostart = true;
 
 // 플래이어 세팅
 WindowMediaPlayer(Player,url,autostart);
}

//-->
</script>
</head>
<body onload="init_me()" oncontextmenu="return false" onselectstart="return false" ondragstart="return false" onkeydown="return false">
<table>
    <tr height="500">
        <td width="700">
            <OBJECT ID="Player" CLASSID="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" width="325" height="315">
                <PARAM name="URL" value="mms://mmc.daumcast.net/mmc/1/500/0902600000101h.wmv"/>
                <PARAM name="autostart" value="false"/>

                <PARAM name="enablecontextmenu" value="0"/>
            </object>
        </td>
    </tr>
</table>

<!--
<b>초기화 : </b>
<input type="button" value="초기화" onclick="init_me()">
<br>
-->

<b>재생 : </b>
<input type="button" value="재생" onclick="player_play();">
<input type="button" value="정지" onclick="player_stop();">
<input type="button" value="일시정지" onclick="player_pause();">
<input type="button" value="빨리감기" onclick="player_fastForward();">
<input type="button" value="되감기" onclick="player_fastReverse();">
<input type="button" value="2배속" onclick="player_setRate(2);">
<input type="button" value="3배속" onclick="player_setRate(3);">
<br/>

<b>소리 : </b>
<input type="button" value="+10" onclick="player_addVolume(10);">
<input type="button" value="-10" onclick="player_addVolume(-10);">
<input type="button" value="0%" onclick="player_setVolume(0);">
<input type="button" value="100%" onclick="player_setVolume(100);">
&nbsp;&nbsp;음소거 <input type="checkbox" onclick="player_mute(this.checked);">
<br/>

<b>화면 : </b>
<input type="button" value="정상" onclick="player_resize(0);">
<input type="button" value="50%" onclick="player_resize(1);">
<input type="button" value="200%" onclick="player_resize(2);">
<input type="button" value="전체화면" onclick="player_resize(3);">
<br/>

<b>이동 : </b>
<input type="button" value="처음" onclick="player_setPosStart();">
<input type="button" value="마지막" onclick="player_setPosEnd();">
<input type="button" value="처음에서 20초" onclick="player_setPos(20);">
<input type="button" value="10초전" onclick="player_addPos(-10);">
<input type="button" value="10초후" onclick="player_addPos(10);">
<input type="button" value="처음에서 200프레임" onclick="player_setPosFrame(200);">
<input type="button" value="100프레임전" onclick="player_addPosFrame(-100);">
<input type="button" value="100프레임후" onclick="player_addPosFrame(100);">
<br/>

</body>
</html>

[출처] Media Player 제어|작성자 풀다

Posted by 아로스

Byte Check

Windows/JAVASCRIPT 2009. 9. 17. 14:17

function calculateBytes( szValue)
{
  var tcount = 0;

  var tmpStr = new String(szValue);
  var temp = tmpStr.length;

  var onechar;
  for ( k=0; k<temp; k++ )
  {
    onechar = tmpStr.charAt(k);
    if (escape(onechar).length > 4)
    {
      tcount += 2;
    }
    else
    {
      tcount += 1;
    }
  }

  return tcount;
}

Posted by 아로스

자바스크립트에서.. split 을 쓸경우..

var s_data = "2005-03-25";  // 잘라야 되는 값..

var array_data = s_data.split("-");  // split 함수사용..

var s_year = array_data[0];   // 잘라진 값 배열..
var s_month = array_data[1];
var s_day = array_data[2];

Posted by 아로스
  x.style.backgroundColor = color;  //backgroundcolor를 color에 들어있는 값으로 하라.
  x.style.width = "400px";  //넓이값.이렇게 px로 넣어도 된다.
  x.style.height = "300";   //높이값.이렇게 숫자를 넣어도 되고
  x.style.color = "#FFFFFF";  //글자색
  x. style.fontWeight = "bold";  //글자색 진하게.
  x. style.border = "4px solid black";  //테두리를 4px로 주라.

//x. style.background = "url(1.jpg) no-repeat";  background에 이미지깔기도 가능.
//style객체. style의 모든 속성은 다 사용할 수 있다.
Posted by 아로스

<script>
 test=window.open ( "http://kr.yahoo.com","tst","location=no,scrollbars=yes,menubar=no,resizable=yes,status=yes, toolbar= no,width=400,height=350,left=100,top=50");

/*

 첫번째 항목은 새창의 주소, 두번째는 새창의 이름, 세번째 부터는 창의 속성인데요,

location은 주소

scrollbars는 스크롤바 생성유무,

menubar는 메뉴바유무

resizable은 창의 크기 리사이즈 가능여부,

status는 상태표시줄 표시여부 구요,

toolbar는 툴바표시여부

width는 창의 너비

height는 창의 높이

left는 창의 가로위치

top은 창의 세로위치입니다.

*/
</script>

Posted by 아로스
<script type="text/javascript">

var s = commify(-1234567890.123);
document.write(s + '<br />');
// 출력 결과: -1,234,567,890.123


function commify(n) {
  var reg = /(^[+-]?\d+)(\d{3})/;   // 정규식
  n += '';                          // 숫자를 문자열로 변환

  while (reg.test(n))
    n = n.replace(reg, '$1' + ',' + '$2');

  return n;
}

</script>
Posted by 아로스

가격 콤마

Windows/JAVASCRIPT 2009. 4. 28. 19:11


<script>

function Set_Comma(n){
  return Number(String(n).replace(/\..*|[^\d]/g,"")).toLocaleString().slice(0,-3);
}
</script>
<BODY>
<FORM name="frm">
  
<input type="text" maxlength="20" name="amount" style=" text-align:right;" onkeyup="this.value = Set_Comma(this.value);">
</FORM>

Posted by 아로스
12

아로스

달력

05-18 17:56