2009-05-17 6 views
0

사용자 스 니펫에 맞게 이미지로드를 조정할 수 있도록 작은 스 니펫을 만들려고합니다. 그런 다음 사용자가 실제 이미지 크기와 해상도에 맞게 조정 된 이미지 크기간에 전환 할 수있게합니다. 여기에 지금까지 가지고있는 작업은 다음과 같습니다자바 스크립트 : 이미지를 창에 맞게 크기 조정 한 다음 전체 크기를 전환하고 클릭시 크기를 조정 하시겠습니까?

<img src="<?=$file['direct_url']?>" border="0" onload="if(this.width>screen.width/1.5) {this.width=screen.width/1.5;this.alt='Click image to view full size';}window.status=this.width;" onmouseover="if(this.alt) this.style.cursor='hand';" onclick="if (this.width=screen.width/1.5) {this.width=screen.width*1.5} else {this.width=screen.width/1.5}"> 

어떤 도움이 크게 감사합니다!

+0

, 문제 무엇인가? –

답변

0

당신이 필요할지도 모르는 유일한 것은/height로 원본 이미지를 저장하는 사용자 지정 특성이라고 생각합니다.

<img originalwidth="100" originalheight="100" /> 

당신은 사용하여 그 값을 사용/검색 할 수 있습니다

그래서
this.getAttribute('originalwidth'); 
this.getAttribute('originalheight'); 
관련 문제