PDA

View Full Version : I cant create a popup window



jazzmatazz2005
09-02-2003, 09:27 AM
This should be nonthing to all you vets but I need to know how to create a regular popup window to use in my web site www.rockdamic.com. Please help me out with this or tell me where i can go to find out how to do it.

thanks

Paulo
09-02-2003, 10:40 AM
OK, this one works for me...

Put this code in your head tags...

<script language="JavaScript" src="pop-up.js"></script>

Save this code as pop-up.js...

function popupWindow(win,winWidth,winHeight,place,winName){
leftPos = 0; topPos = 0;
if (screen){
if (winWidth>screen.width){
winWidth = screen.width;
}
if (winHeight>screen.height){
winHeight = screen.height - 55;
}
if (winWidth <= 0){
winWidth = screen.width;
}
if (winHeight <= 0){
winHeight = screen.height - 55;
}
if (place == 'centre'){ // centres window
leftPos = screen.width/2 - winWidth/2;
topPos = screen.height/2 - winHeight/2;
}
}
newWindow = window.open(win,winName,'toolbar=no,location=no,sc rollbars=yes,
resizable=no,width='+winWidth+',height='+winHeight +',left='+leftPos+',top='+topPos+'');
// newWindow = window.open(win,winName,'alwaysRaised=yes,titlebar =no,toolbar=no,
location=no,scrollbars=auto,resizable=no, width='+winWidth+',height='+winHeight+',
left='+leftPos+',top='+topPos+'');
newWindow.focus();
}

function right(e) {
if (navigator.appName == 'Netscape' &&
(e.which == 3 || e.which == 2))
return false;
else if (navigator.appName == 'Microsoft Internet Explorer' &&
(event.button == 2 || event.button == 3)) {
alert("Sorry, right click is not available on this page");
return false;
}
return true;
}

document.onmousedown=right;
document.onmouseup=right;
if (document.layers) window.captureEvents(Event.MOUSEDOWN);
if (document.layers) window.captureEvents(Event.MOUSEUP);
window.onmousedown=right;
window.onmouseup=right;

And then use this link, replacing TARGET-URL for the filename of the target, WIDTH and HEIGHT for the pixel value size of the window.


Click here to open in a pop-up window (javascript:popupWindow('TARGET-URL',WIDTH,HEIGHT,'centre','cdemoWindow'))

There's a no-right-click function in there you can rid of if you need to

Hope that helps...