Im getting an Error (ie) 'undefined' relating to the path of a clicked image. How to define its path please? Full working code supplied

error seems to be in this line

Function('onclick=jkpopimage(this.src,600,500);');

where 'this.src' is undefined?

<html>
<head>
<script type='text/javascript'>
// for free JavaScript tutorials and scripts
// This notice must stay intact for use

var popbackground="http://i14.photobucket.com/albums/a345/Instar/greenbgfade17oi.jpg"; //specify backcolor or background image for pop window
var windowtitle="Image Viewer" ; //pop window title

function detectexist(obj){
return (typeof obj !="undefined");
}

function jkpopimage(imgpath, popwidth, popheight, textdescription){
    function getpos(){
        leftpos=(detectexist(window.screenLeft))? screenLeft+document.body.clientWidth/2-popwidth/2 : detectexist(window.screenX)? screenX+innerWidth/2-popwidth/2 : 0
        toppos=(detectexist(window.screenTop))? screenTop+document.body.clientHeight/2-popheight/2 : detectexist(window.screenY)? screenY+innerHeight/2-popheight/2 : 0
        if (window.opera){
            leftpos-=screenLeft;
            toppos-=screenTop;
        }
    }
    getpos()
    var  winattributes = 'width='+popwidth+', height='+popheight+', resizable=yes,scrollbars=yes, left='+leftpos+', top='+toppos;
    var bodyattribute = 'topmargin=0 leftmargin=0 background='+popbackground;
    if (typeof jkpopwin=="undefined" || jkpopwin.closed){
        jkpopwin = window.open("","",winattributes);
    } else {
        //getpos() //uncomment these 2 lines if you wish subsequent popups to be centered too
        //jkpopwin.moveTo(leftpos, toppos)
        jkpopwin.resizeTo(popwidth, popheight+30);
    }
    jkpopwin.document.open();
    jkpopwin.document.write('<html><title>'+windowtitle+'</title><body '+bodyattribute+'><img src="'+imgpath+'" style="margin-bottom: 0.5em"><br><center>'+'</body></html>');
    jkpopwin.document.close();
    jkpopwin.focus();
}
</script>


</head>
<body>
<br/><script type="text/javascript">
<!--
/*
Modify image size to fit forum
By Todge
Please keep this header intact
*/

var picWidth = '300'; //Maximum image width..
var picHeight = '300'; //Maximum image height..

var pics = document.images;

window.onload = imageSize;
function imageSize()
{

var p=pics.length-1;
while(p>-1)
{
if(pics[p].getAttribute("alt")=="user posted image")
{
if(pics[p].width>picWidth || pics[p].height>picHeight)
{
var thisPicWidth = picWidth;
if(pics[p].height/(pics[p].width/picWidth)>picHeight)
{
thisPicWidth = pics[p].width/(pics[p].height/picHeight)
}
var newWidth = 100-parseInt(thisPicWidth/pics[p].width*100);
var picLoaded =document.createElement('A');
picLoaded.setAttribute('title','Reduced Image - Click to see full size');
picLoaded.onclick=new
Function('onclick=jkpopimage(this.src,600,500);');
picLoaded.innerHTML = '<font size="0"> Image Reduced by '+newWidth+'%, click to view full size.</font><br><img src="'+pics[p].src+'" width="'+thisPicWidth+'" border="0">';
pics[p].parentNode.replaceChild(picLoaded,pics[p]);
}}
p--;
}}
// -->
</script>
<img src="http://www.eitangrunwald.com/CR703/CR703Web/7204Mesaspis_monticola1.jpg" alt="user posted image"></img>
</body>
</html>

Edited 3 Years Ago by mike_2000_17: Fixed formatting

148 veiws but no replys! what does this mean? how good is daniweb!

This article has been dead for over six months. Start a new discussion instead.