954,593 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

.src undefined error

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?

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

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

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

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==&quot;undefined&quot; || jkpopwin.closed){
		jkpopwin = window.open(&quot;&quot;,&quot;&quot;,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('&lt;html&gt;&lt;title&gt;'+windowtitle+'&lt;/title&gt;&lt;body '+bodyattribute+'&gt;&lt;img src=&quot;'+imgpath+'&quot; style=&quot;margin-bottom: 0.5em&quot;&gt;&lt;center&gt;'+'&lt;/body&gt;&lt;/html&gt;');
	jkpopwin.document.close();
	jkpopwin.focus();
}
&lt;/script&gt;


&lt;/head&gt;
&lt;body&gt;
&lt;br/&gt;&lt;script type=&quot;text/javascript&quot;&gt;
&lt;!--
/*
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&gt;-1)
{
if(pics[p].getAttribute(&quot;alt&quot;)==&quot;user posted image&quot;)
{
if(pics[p].width&gt;picWidth || pics[p].height&gt;picHeight)
{
var thisPicWidth = picWidth;
if(pics[p].height/(pics[p].width/picWidth)&gt;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 = '&lt;font size=&quot;0&quot;&gt; Image Reduced by '+newWidth+'%, click to view full size.&lt;/font&gt;&lt;img src=&quot;'+pics[p].src+'&quot; width=&quot;'+thisPicWidth+'&quot; border=&quot;0&quot;&gt;';
pics[p].parentNode.replaceChild(picLoaded,pics[p]);
}}
p--;
}}
// --&gt;
&lt;/script&gt;
&lt;img src=&quot;http://www.eitangrunwald.com/CR703/CR703Web/7204Mesaspis_monticola1.jpg&quot; alt=&quot;user posted image&quot;&gt;&lt;/img&gt;
&lt;/body&gt;
&lt;/html&gt;</code>
Inny
Posting Whiz in Training
293 posts since Oct 2005
Reputation Points: 11
Solved Threads: 6
 

anyone?

Inny
Posting Whiz in Training
293 posts since Oct 2005
Reputation Points: 11
Solved Threads: 6
 

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

Inny
Posting Whiz in Training
293 posts since Oct 2005
Reputation Points: 11
Solved Threads: 6
 

This is voluenteer effort mate. Wait your turn. (p.s most of those 128 are probably bots/crawlers)

jbennet
Moderator
Moderator
18,523 posts since Apr 2005
Reputation Points: 1,826
Solved Threads: 601
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You