Click to See Complete Forum and Search --> : Problem with popups and if statements!


lloydwatkin
09-05-2003, 08:10 AM
Hi,

Thanks for all that helped me earlier, I have now written a script popup.js which controls the popup window for files in various directories:

function openpopup(popurl,poptitle){


if (poptitle.value == 'undefined')
{
var poptitle = '';
alert(poptitle)
return true;
}

winpops=window.open('','newWin',"width=660,height=500,leftmargin='0',topmargin='0',marginwidth='0',marginheight='0");
winpops.document.write("<HTML><TITLE>"+poptitle+"</TITLE><CENTER><IMG src="+popurl+" ></CENTER></HTML>");
}

Now in my page I have the following two types of link:

<a href="javascript:openpopup('pic004.JPG');return true;"><img src="004.JPG" alt="Alt Text 1"></a>

<a href="javascript:openpopup('pic005.JPG')">
<img src="005.JPG" OnClick="javascript:openpopup('pics/005.JPG',this.alt)" alt="Alt Text 2"></a>

The second type I click on and hey prestop up comes my popup window with alt tag title. The first link however does not work, when clicking on it nothing happens. This only occured when I added the if statement to the popup.js file, this was because when poptitle wasn't being sent by the "a href" link the window title was "undefined" and in this case I'd prefer it to be the file name/directory.

Can anyone help???

Thanks

Lloyd (http://www.evilprofessor.co.uk)

To see the page this relates to goto http://www.evilprofessor.co.uk/photos/egypt/cairo/around/

lloydwatkin
09-05-2003, 08:48 AM
I think I was being a little dumbass here, just needed to change the first type of link to something like:

<a href="javascript:openpopup('pics/004.JPG','' )">

This brings up the link with a title equal to the directory instead of undefined, i.e. no need for the if statement!

Thanks anyway

Lloyd