•
•
•
•
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 363,826 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 4,245 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: 706 | Replies: 3
![]() |
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
where 'this.src' is undefined?
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
W. C. Fields
•
•
Join Date: Apr 2005
Location: Old Hampshire, Old England (LOL)
Posts: 11,938
Reputation:
Rep Power: 30
Solved Threads: 263
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
james.bennet1@ntlworld.com
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb JavaScript / DHTML / AJAX Marketplace
Similar Threads
- Need urgent help: Linkage error with the library (C)
- Function is undefined (JavaScript / DHTML / AJAX)
- Error: "Use of undefined constant" Help! (PHP)
- Ajax Question (ASP.NET)
- linking problems (C++)
- XHTML Validation ??? (JavaScript / DHTML / AJAX)
- Linking Error... (C++)
- I think I'm going to cry... (JSP)
- error when compiling murphy's law with gcc (C)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: click label to select radio button
- Next Thread: over-ride inaccessable javascript function?



Linear Mode