Click to See Complete Forum and Search --> : Problem with popup


giorgio
12-13-2002, 10:11 AM
Hello everyone!!It's my first thread :)
Please,could anyone help me?I'm going crazy...
I've made a HTML page: I have one small picture in it and I'd like opening it (after clicking on it) in a popup whose size is the one of the picture.
I've found the following JavaScript: the problem is that it perfectly works in local (before uploading my page to my remote server) and the popup opens regularly. When I upload my page to my remote server, the popup doesn't open!!! I really can't find the reason!!! :(
Thanks to all the people who will be so kind as to help me...
Bye!!

PS: I use Dreamweaver MX




I've put between the <head> the following:

<script language="JavaScript">
<!--

function SymError()
{
return true;
}

window.onerror = SymError;

var SymRealWinOpen = window.open;

function SymWinOpen(url, name, attributes)
{
return (new Object());
}

window.open = SymWinOpen;

//-->
</script>

<SCRIPT LANGUAGE="JavaScript1.2">
var finestra;
var undef;
var x0,y0,titolo;
function popup(wid,hei,immagine,titolo) {
if (typeof finestra != "undefined") finestra.close();
x0 = Math.floor((screen.width - wid) / 2);
y0 = Math.floor((screen.height - hei) / 2);
finestra = window.open("","","width=" + wid + " ,height=" + hei +
" ,left=" + x0 + ",top=" + y0);
finestra.document.write("<IMG SRC=" + immagine + " WIDTH=" + wid + " HEIGHT=" +
hei + " BORDER='0' STYLE='position:absolute; left:0px; top:0px'>");
finestra.document.title = titolo;
}
function chiudi() {
if (typeof finestra != "undefined") {
finestra.close();
finestra = undef;
}
}
</SCRIPT>


Then, I've put this code inside the body of my HTML page:

<A HREF="javascript:" onClick="popup(400,300,'bigpicture.jpg','Titolo')"><img src="smallpicture.jpg" alt="" width="40" height="30" border="0"></A>


At the end,after closing the body:

<script language="JavaScript">
<!--

window.open = SymRealWinOpen;

//-->
</script>

ShrineDesigns
12-13-2002, 12:54 PM
this fixes you "popup" function

<html>
<head>
<script language="JavaScript">
<!--
function SymError(){
window.onError = "SymError";
}

function SymWinOpen(url,name,attributes){
window.open(url,name,attributes);
}

function popup(url,winName,W,H){
x = Math.floor((screen.width - W) / 2);
y = Math.floor((screen.height - H) / 2);
fineStr = window.open(url,winName,'width=' + W + '','height=' + H + '','left=' + x + '','top=' + y + ''); // document.write will override the url
fineStr.document.write('<html>\n<head>\n<title>' + winName + '<\/title>\n<\/head>\n<body style=\"margin:0px;\">\n<IMG SRC=\"' + url + '\" WIDTH=\"' + W + '\" HEIGHT=\"' + H + '\" BORDER=\"0\" STYLE=\"position:absolute; left:0px; top:0px\">\n<\/body>\n<\/html>\n');
}

var undef = "";
function chiudi(){
if (typeof finestra != "undefined"){
fineStr.close();
fineStr = undef;
}
}
//-->
</script>
</head>
<body onLoad="SymWinOpen('myDocument.html','myWindow','height=200 width=200')">
<A HREF="javascript:void(0);" onClick="popup('bigpicture.jpg','Titolo',400,300)"><img src="smallpicture.jpg" alt="" width="40" height="30" border="0"></A>
</body>
</html>

i have no idea what your other functions do but "SymRealWinOpen" is not properly coded

giorgio
12-13-2002, 02:23 PM
Thank you!!