Прозорче

vik96

Registered
как да направа като се натисне на определена картинка да ми излиза прозорец с определени размери !
 
Код:
<script>
function MM_openBrWindow(theURL,winName,features) {
  if (IsPopupBlocker()) {	
    alert("To view this page please disable 'popup block' ");
  } else {	  window.open(theURL,winName,features + ",top=5,left=5");  }	

}
function IsPopupBlocker() {
	var oWin = window.open("","popupblockertest","width=100,height=50,top=5000,left=5000");
	if (oWin==null || typeof(oWin)=="undefined") { return true;	} 
	else {
		oWin.close();
		return false;
	}
}
</script>
<a href="javascript: MM_openBrWindow('http://abv.bg','desktop','width=500,height=500,top=0,left=0')"><img src="снимка"></a>
 
<script type="text/javascript">
var newWindow = null;

function openWindow(contentURL,windowName,windowWidth,windowHeight) {
widthHeight = 'height=' + windowHeight + 'width=' + windowWidth;
newWindow = window.open(contentURL,windowName,widthHeight);
newWindow.focus()
}

function closeWindow() {
if(newWindow != null) {
newWindow.close();
newWindow = null;
}
}

function toggleWIndow(contentURL,windowName,windowWidth,windowHeight) {
if (newWindow == null) {
widthHeight = 'height=' + windowHeight + 'width=' + windowWidth;
newWindow = window.open(contentURL,windowName,widthHeight);
newWindow.focus()
} else {
newWindow.close();
newWindow = null;
}
}
</script>
<img src="kartinka.jpg" onclick="javascript:openWindow('prozorec.html','myNewWindow', 300, 50)" />


и вариант 2:


<script type="text/javascript">
var newWindow = null;

function openWindow(contentURL,windowName,windowWidth,windowHeight) {
widthHeight = 'height=' + windowHeight + 'width=' + windowWidth;
newWindow = window.open(contentURL,windowName,widthHeight);
newWindow.focus()
}

function closeWindow() {
if(newWindow != null) {
newWindow.close();
newWindow = null;
}
}

function toggleWIndow(contentURL,windowName,windowWidth,windowHeight) {
if (newWindow == null) {
widthHeight = 'height=' + windowHeight + 'width=' + windowWidth;
newWindow = window.open(contentURL,windowName,widthHeight);
newWindow.focus()
} else {
newWindow.close();
newWindow = null;
}
}
</script>
<a href="javascript:openWindow('prozorec.html','myNewWindow', 300, 50)"><img src="kartinka.jpg" /> </а>


prozorec.html - страницата, която искаш да се зарежда
kartinka.jpg - линк към картинката
50 - височината на новия прозорец
300 - широчината на новия прозорец


Другото не го пипай, че скрипта няма да работи ако не знаеш какв правиш :)
 

Back
Горе