User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 426,898 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,359 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 895 | Replies: 3
Reply
Join Date: Oct 2005
Posts: 236
Reputation: Inny is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 5
Inny's Avatar
Inny Inny is offline Offline
Posting Whiz in Training

.src undefined error

  #1  
May 13th, 2008
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>
Always carry a flagon of whiskey in case of snakebite and furthermore always carry a small snake.
W. C. Fields
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Oct 2005
Posts: 236
Reputation: Inny is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 5
Inny's Avatar
Inny Inny is offline Offline
Posting Whiz in Training

Re: .src undefined error

  #2  
May 13th, 2008
anyone?
Always carry a flagon of whiskey in case of snakebite and furthermore always carry a small snake.
W. C. Fields
Reply With Quote  
Join Date: Oct 2005
Posts: 236
Reputation: Inny is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 5
Inny's Avatar
Inny Inny is offline Offline
Posting Whiz in Training

Re: .src undefined error

  #3  
May 16th, 2008
148 veiws but no replys! what does this mean? how good is daniweb!
Always carry a flagon of whiskey in case of snakebite and furthermore always carry a small snake.
W. C. Fields
Reply With Quote  
Join Date: Apr 2005
Location: Old Hampshire, Old England (LOL)
Posts: 11,937
Reputation: jbennet is a jewel in the rough jbennet is a jewel in the rough jbennet is a jewel in the rough jbennet is a jewel in the rough 
Rep Power: 30
Solved Threads: 268
Moderator
Featured Poster
jbennet's Avatar
jbennet jbennet is offline Offline
Microsoft Fanboy

Re: .src undefined error

  #4  
May 19th, 2008
This is voluenteer effort mate. Wait your turn. (p.s most of those 128 are probably bots/crawlers)
TRY MY SUGGESTIONS AT YOUR OWN RISK!
james.bennet1@ntlworld.com
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb JavaScript / DHTML / AJAX Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the JavaScript / DHTML / AJAX Forum

All times are GMT -4. The time now is 10:54 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC