부모창
<select name="show_in" id="show_data">
	<option value="aaa">aaa</option>
</select>
<input onclick="open_show()" value="click" type="button"/>

<script type="text/javascript">
function open_show(url) {
	window.open("jasu_input_show.html", "win", "");
}
function test(data){		
	var objSelect = document.getElementById("show_data"); 
	var dataLength = data.length;
	for(var i=0; i<dataLength; i++) {
		var objOption = document.createElement("OPTION");
		objOption.appendChild(document.createTextNode(data[i].text)); //텍스트 노드를 생성해서 추가한다.
		objOption.value = data[i].value;       
		objSelect.appendChild(objOption);      //자식 노드를 추가한다.
	}
}
</script>
팝업창
<script type="text/javascript">
	var data = [ {text:"tt1", value:"tt1"}, {text:"tt2", value:"tt2"}];	//json 형태의 데이터
</script>
<input onclick="opener.test(data)" value="click" type="button">
Posted by 피곤키오
,

새창 열기 기몬 유형

자바스크립트에서 새창을 열때에는 다음과 같이 사용합니다.
window.open('문서경로', 'window', 'location=no, directories=no, resizable=no, status=no, toolbar=no, menubar=no, width=300, height=400, left=0, top=0, scrollbars=yes')
//location : 주소표시줄 //directoryies : 연결 //resizable : 크기조절 //status : 상태표시줄 //toolbar : 표시단추 //memubar : 메뉴 //width : 새창 너비 // height : 새창 높이 //left : 새창 왼쪽 위치 //top : 새창 위쪽 위치

* yes와 no대신 1과 0을 사용해도 됩니다.

 

새창 열기 사용 방법

a 링크 태그에서 스크립트를 사용하여 페이지를 새창으로 여는 경우에는 href에 새창으로 열 페이지 주소를 적고 자바스크립트에는 this.href를 넘겨줍니다.
웹접근성과 관련하여 자바스크립트가 동작하지 않는 브라우저의 경우에도 동일하게 동작하게 하기 위해서 입니다.



클릭

 

팝업창 자동으로 리사이즈 하기


Posted by 피곤키오
,

JavaScript CoverFlow 2.0 (jCoverFlow)

라이브러리는 이곳에서 다운로드 받습니다.
http://jcoverflow.sourceforge.net/

jCoverFlow_2.0.rar 파일을 다운로드해서 압축풀면, coverflow.js와 coverflow.css이 있습니다.

이런 형식의 html을 원하는 위치에 넣고,

<div id="coverflowHolder"> 
    <div id="__cvfl-coverflow-holder" style="display:none"> 
        <div id="__cvfl-coverflow"> 
            <div id="__cvfl-coverflow-wrapper"></div> 
            <div id="smallerPreview"></div> 
            <div id="__cvfl-coverflow-label"></div> 
        </div> 
    </div> 
</div>

아래와 같이 자바스크립트에서 호출해주면 됩니다.

Coverflow.init([리스트배열], {createLabel, onSelectCenter, refill});

리스트배열에는 [{src, labelObject}] 형식으로 src는 이미지 주소를 넣고, labelObject는 선택되었을 때 넣을 데이터를 넣으면 나중에 보여줄 때 편리하게 하는 것 같습니다. 그리고, 함수정의로 createLabel은 현재위치의 coverflow의 정보를 보여주기 위한 html을 리턴하는 함수입니다. onSelectCenter는 선택된 것 클릭했을 때 액션이고, refill은 잘 모르겠습니다.

주의사항은 자바스크립트가 HTML보다 나중에 와야됩니다.

실제 예제에서 보면 다음과 같이 사용합니다.

<SCRIPT type="text/javascript">
	if (canvas_compatible) 
	{	
		window.onload = function()
		{	
			Coverflow.init([
				{src: 'CoverFlows_files/covers/cover1med.jpg',
				  label: {album: 'Abbey Road', artist: 'The Beatles', url:'http://www.beatles.com/', high:'CoverFlows_files/covers/cover1large.jpg'}},
				{src: 'CoverFlows_files/covers/cover2med.jpg',
				   label: {album: 'Graduation', artist: 'Kanye West', url:'http://www.kanyewest.com', high:'CoverFlows_files/covers/cover2large.jpg'}},
				{src: 'CoverFlows_files/covers/cover3med.jpg',
				   label: {album: 'Circus', artist: 'Britney Spears', url:'http://www.britneyspears.com', high:'CoverFlows_files/covers/cover3large.jpg'}},			   
				{src: 'CoverFlows_files/covers/cover13med.jpg',
				   label: {album: 'The Fame', artist: 'Lady Gaga', url:'http://www.ladygaga.com', high:'CoverFlows_files/covers/cover13large.jpg'}},			   
				{src: 'CoverFlows_files/covers/cover14med.jpg',
				   label: {album: 'The Fray', artist: 'The Fray', url:'http://www.thefray.com', high:'CoverFlows_files/covers/cover14large.jpg'}},			   
				{src: 'CoverFlows_files/covers/cover12med.jpg',
				   label: {album: 'Funhouse', artist: 'Pink', url:'http://www.pinkspage.com', high:'CoverFlows_files/covers/cover12large.jpg'}},
				{src: 'CoverFlows_files/covers/cover4med.jpg',
				   label: {album: '21st Century Breakdown', artist: 'Greenday', url:'http://www.greenday.com', high:'CoverFlows_files/covers/cover4large.jpg'}},
				{src: 'CoverFlows_files/covers/cover5med.jpg',
				   label: {album: 'Carter III', artist: 'Lil Wayne', url:'http://www.lilwayne.com', high:'CoverFlows_files/covers/cover5large.jpg'}},
				{src: 'CoverFlows_files/covers/cover6med.jpg',
				   label: {album: 'Clumsy', artist: 'Fergie', url:'http://www.fergie.com', high:'CoverFlows_files/covers/cover6large.jpg'}},
				{src: 'CoverFlows_files/covers/cover7med.jpg',
				   label: {album: 'The Best Of', artist: 'Blur', url:'http://ww.blur.com', high:'CoverFlows_files/covers/cover7large.jpg'}},
				{src: 'CoverFlows_files/covers/cover8med.jpg',
				   label: {album: 'Rockferry', artist: 'Duffy', url:'http://www.duffy.com', high:'CoverFlows_files/covers/cover8large.jpg'}},
				{src: 'CoverFlows_files/covers/cover9med.jpg',
				   label: {album: 'Dig out your soul', artist: 'Oasis', url:'http://www.oasis.com', high:'CoverFlows_files/covers/cover9large.jpg'}},
				{src: 'CoverFlows_files/covers/cover10med.jpg',
				   label: {album: 'Loose', artist: 'Nelly Furtado', url:'http://www.nellyfurtado.com', high:'CoverFlows_files/covers/cover10large.jpg'}}		   
			],
			{	
				createLabel: function(item)
				{			
					return item.label.album +'<br><span id="artist">'+ item.label.artist + '</span><br><a href="' + item.label.url + '">'+item.label.url+'</a>';
				 
				},

				onSelectCenter: function(item,id) 
				{		
					var img = new Image();
					img.onload = function()
					{ 		
						Lightbox.show(this.src,id);	
			
					}; 		
					img.src = item.label.high;		
				},		

				refill: function(start)
				{
				new HTTPQuery("/ajax/cflow/0/?from="+start+"&l=1&cache=3998668924011356071",0,"updateCflow");
				}		
			});
		}
	}
	
	function updateCflow(oHttp) {
		cResponse = oHttp.responseText;
		if (cResponse.substr(0,1)=="!"){
			cResponse=cResponse.substr(1);
			eval(cResponse);
		}
	}
</SCRIPT>
Posted by 피곤키오
,
첫번째 방법
<script type="text/javascript">
function autoResize(i) {
   var iframeHeight=
   (i).contentWindow.document.body.scrollHeight;
   (i).height=iframeHeight+20;
}
</script>

<iframe onload="autoResize(this)" id="tree"></iframe>

 

두번째 방법
<script type="text/javascript">
function autoIframe(frameId){
	try{
		frame = document.getElementById(frameId);
		innerDoc = (frame.contentDocument) ? frame.contentDocument : frame.contentWindow.document;
		objToResize = (frame.style) ? frame.style : frame;
		objToResize.height = innerDoc.body.scrollHeight + 10;
	}
	catch(err){
		window.status = err.message;
	}
}
</script>

<iframe id="tree" name="tree" src="tree.htm" onload="if (window.parent && window.parent.autoIframe) {window.parent.autoIframe('tree');}"></iframe> 
Posted by 피곤키오
,