
02-24-08, 11:15 PM
|
|
Newbie Coder
|
|
Join Date: Feb 2007
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
|
links not working in JS
Hi,
I have the following code, which when executed places images at the given absolute co-ordinates. The arrays include addresses, but even though the curser changes to hand when hovering over the image, the image does not link.
I can not figure out what is missing.
Any help would be very much appreciated.
javascript Code:
var Path='website.com/images/' var ImgAry=[]; ImgAry[0]=['photos/architecture/arch_01.jpg','','<br><br>seoul airport<br>terry farrell & partners',229,250]; ImgAry[1]=['photos/architecture/arch_02.jpg','','<br><br>hong kong residence<br>adrian mccarroll architects',603,78]; ImgAry[2]=['photos/architecture/arch_03.jpg','website.com,'<br><br>silodam amsterdam<br>mvrdv',638,78]; ImgAry[3]=['photos/architecture/arch_04.jpg','website.com','<br><br>kings villa beijing',472,202]; ImgAry[4]=['photos/architecture/arch_05.jpg','website.com','<br><br>library hotel koh samui',517,145]; ImgAry[5]=['photos/architecture/arch_06.jpg','website.com','<br><br>shanghai airport <br>paul andreu architect',417,225]; ImgAry[6]=['photos/architecture/arch_07.jpg','website.com','<br><br>twin towers reception<br>mpi architects',472,202]; ImgAry[7]=['photos/architecture/arch_08.jpg',website.com','<br><br>china national offshore oil company<br>kohn pederson fox architects',543,57]; ImgAry[8]=['photos/architecture/arch_09.jpg','website.com','<br><br>quanta touyuan<br>artech architects',392,249]; ImgAry[9]=['photos/architecture/arch_10.jpg',website.com/beijing_olympic.php','<br><br>beijing olympic boom<br><br><br><br><br><br><br>Click <a href="beijing_olympic.php" style="text-decoration:none; color:#666666"><b>here</b></a> to view all photos of the beijing olympic boom',110,242]; ImgAry[10]=['photos/architecture/arch_11.jpg','website.com','<br><br>walvis amsterdam<br>frits van dongen architecten cie',517,145]; ImgAry[11]=['photos/architecture/arch_12.jpg','website.com','<br><br>office and apartment buildings in the far east',110,337]; ImgAry[12]=['photos/architecture/arch_13.jpg','website.com','<br><br>bibliotheek amsterdam<br>jo coenen architecten',596,78]; ImgAry[13]=['photos/architecture/arch_14.jpg','website.com','<br><br>banciao model house taipei<br>kuo architects',229,243]; ImgAry[14]=['photos/architecture/arch_15.jpg','website.com','<br><br>commercial building<br>neihu ksarch',472,202]; ImgAry[15]=['photos/architecture/arch_16.jpg','website.com','<br><br>exhibition center melbourne<br>denton corker marshall',594,73]; ImgAry[16]=['photos/architecture/arch_17.jpg','website.com','<br><br>childrens palace guangzho china<br>steffan bradley architects',599,78]; ImgAry[17]=['photos/architecture/arch_18.jpg','website.com','<br><br>shiatze chen factory shanghai<br>layan design group',472,202]; ImgAry[18]=['photos/architecture/arch_19.jpg','website.com','<br><br>childrens palace guangzho china<br>steffan bradley architects',472,202]; ImgAry[19]=['photos/architecture/arch_20.jpg','website.com','<br><br>pukhet residence <br>adrian mccarroll architects',472,202]; for (var zxc0=0;zxc0<ImgAry.length;zxc0++){ ImgAry[zxc0][10]=new Image(); ImgAry[zxc0][10].src=Path+ImgAry[zxc0][0]; } // Functional Code var zxcTO; var ImgCnt=0; var zxcEvt=0; function zxcStyle(zxcele,zxcstyle,zxcp){ if (typeof(zxcele)=='string'){ zxcele=document.createElement(zxcele); } for (key in zxcstyle){ zxcele.style[key]=zxcstyle[key]; } if (zxcp){ zxcp.appendChild(zxcele); } return zxcele; } function zxcEventAdd(zxco,zxct,zxcf) { if ( zxco.addEventListener ){ zxco.addEventListener(zxct, function(e){ zxco[zxcf](e);}, false); } else if ( zxco.attachEvent ){ zxco.attachEvent('on'+zxct,function(e){ zxco[zxcf](e);}); } else { var zxcPrev=zxco["on" + zxct]; if (zxcPrev){ zxco['on'+zxct]=function(e){ zxcPrev(e); zxco[zxcf](e); }; } else { zxco['on'+zxct]=zxco[zxcf]; } } } function zxcAddEvent(zxc,zxcfun,zxcevt){ if (zxc.addEvent){ return; } zxc.addEvent=window[zxcfun]; zxcEventAdd(zxc,zxcevt,'addEvent'); } function zxcAddEvt(zxc,zxcfun,zxcevt){ zxc['zxcaddEvt'+zxcEvt]=window[zxcfun]; zxcEventAdd(zxc,zxcevt,'zxcaddEvt'+zxcEvt); zxcEvt++; } // parameters 0 = column pitch, 1 = row pitch, 2 = dot height, 3 = slide show button height function PlaceDots(zxccol,zxcrow,zxcdotheight,zxcssheight){ zxcnu=ImgAry.length; var zxcp=document.getElementById('dots'); zxcp.removeChild(zxcp.getElementsByTagName('DIV')[0]); var zxclft=0;zxctop=0; for (var zxc0=0;zxc0<zxcnu;zxc0++){ var zxcimg=zxcStyle('IMG',{position:'absolute',left:(Math.floor(zxc0%(zxcnu/2))*zxccol)+'px',top:(Math.floor(zxc0/(zxcnu/2))*zxcrow)+'px',cursor:(document.all)?'hand':'pointer'},zxcp); zxcimg.src=Path+'dots/dots'+(Math.floor(zxc0%(zxcnu/2))+1)+'.gif'; zxcAddEvt(zxcimg,'zxcDotMse','mouseover'); zxcAddEvt(zxcimg,'zxcDotMse','mouseout'); } zxcdimg=zxcStyle('IMG',{width:'43px',height:zxcssheight+'px',position:'absolute',left:(Math.ceil(zxcnu/2)*zxccol)+'px',top:((zxcrow+zxcdotheight-zxcssheight)/2)+'px'},zxcp); zxcdimg.src=Path+'dots/slidedot.gif'; zxcAddEvt(zxcdimg,'zxcStartSShow','mouseover'); zxcAddEvt(zxcdimg,'zxcStartSShow','mouseout'); zxcStyle(document.getElementById('Main'),{cursor:(document.all)?'hand':'pointer'}); } function zxcDotMse(zxcevt){ clearTimeout(zxcTO); var zxcdots=this.parentNode.getElementsByTagName('IMG'); for (var zxc0=0;zxc0<zxcdots.length;zxc0++){ if (zxcdots[zxc0]==this){ ImgCnt=zxc0; break; } } PlaceImage(); } function zxcStartSShow(zxcevt){ zxcevt.cancelBubble=true; if (zxcevt.stopPropagation) zxcevt.stopPropagation(); clearTimeout(zxcTO); if (zxcevt.type=='mouseover'){ this.src=Path+'dots/slidedotred.gif'; SlideShow(); } else { this.src=Path+'dots/slidedot.gif'; } } function SlideShow(){ PlaceImage(); ImgCnt=++ImgCnt%ImgAry.length; zxcTO=setTimeout('SlideShow()',3000); } function PlaceImage(){ var zxcimg=document.getElementById('Main') zxcStyle(zxcimg,{left:ImgAry[ImgCnt][3]+'px',top:ImgAry[ImgCnt][4]+'px'}); zxcimg.src=Path+ImgAry[ImgCnt][0]; document.getElementById('text').innerHTML=ImgAry[ImgCnt][2]; ResetDots(); } function ResetDots(){ var zxcimgs=document.getElementById('dots').getElementsByTagName('IMG'); var zxcmid=Math.ceil((zxcimgs.length-1)/2); for (var zxc0=0;zxc0<zxcimgs.length-1;zxc0++){ zxcimgs[zxc0].src=Path+'dots/dots'+((zxc0<zxcmid)?zxc0+1:zxc0-zxcmid+1)+'.gif'; } zxcimgs[ImgCnt].src=Path+'dots/dotred.gif'; } /*]]>*/ </script> <body > <div id="loading" style="position:absolute; left:895px;top:556px;"> <img src="../images/loading.gif" border=0 /></div> <a href="website.com"><img src="website.com/images/name_heading.gif" width="220" height="17" style="position:absolute;left:110px;top:74px;" border="0" /></a> <div id="text" style="position:absolute;left:110px;top:105px;width:320px;height:50px;text-Align:left;font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10px; color: #999999;text-decoration: none; line-height: 10pt;" ><br><br>seoul airport<br>terry farrell & partners</div> <div id="dots" style="position:absolute;left:110px;top:176px;" > <div style="font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 9px; color: #999999;"></div> </div > <img id="Main" src="website.com/images/photos/architecture/arch_01.jpg" style="position:absolute;left:229px;top:250px;" /> <img id="Main" src="website.com/images/horline.gif" width="857" style="position:absolute;left:110px;top:590px;" /> <script language="JavaScript" type="text/javascript"> /*<![CDATA[*/ // parameters 0 = column pitch, 1 = row pitch, 2 = dot height, 3 = slide show button height PlaceDots(22,20,17,44); /*]]>*/ </script>
Last edited by mab; 02-24-08 at 11:30 PM.
Reason: Code in code tags please.
|

02-25-08, 06:07 AM
|
 |
Community Liaison
|
|
Join Date: May 2005
Location: Antwerp, Belgium
Posts: 3,165
Thanks: 4
Thanked 25 Times in 25 Posts
|
|
When I just look at the syntax coloring of your code, I already see you're missing a couple of quotes. Try fixing these problems and see what happens
__________________
"Good judgement comes from experience, and experience comes from bad judgement." - Fred Brooks
|

02-25-08, 06:32 AM
|
|
Newbie Coder
|
|
Join Date: Feb 2007
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thanks but that was only due to clumsy copy and pasting on my behalf.
Original codes have got no color coding indications of missing quotes. I double checked and found none to be missing
|

02-25-08, 07:09 AM
|
 |
Community VIP
|
|
Join Date: Oct 2005
Location: Denver, Co. USA
Posts: 2,674
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I'm afraid that no one in a forum is going to spend time on code that is not accurately posted.
Your original post just listed the code as part of the post. It is possible that doing that caused some of the quotes to be treated as real quotes instead of literal characters. It is also possible that adding [highlight=javascript] ... [/highlight] tags around the code after the fact altered it, but unlikely.
I recommend that you repost the correct code and surround it in [highlight=javascript] Your Code Here [/highlight] tags.
__________________
Error checking, error reporting, and error recovery. If your code does not have these to get it to tell you why it is not working, what makes you think someone in a programming forum will be able to tell you why it is not working???
Last edited by mab; 02-25-08 at 07:12 AM.
Reason: fix hightlight tag to not be parsed - [noparse] does not work
|

02-25-08, 08:10 AM
|
|
Newbie Coder
|
|
Join Date: Feb 2007
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
javascript Code:
var Path='http://www.website.com/images/' var ImgAry=[]; ImgAry[0]=['photos/architecture/arch_01.jpg','','<br><br>seoul airport<br>terry farrell & partners',229,250]; ImgAry[1]=['photos/architecture/arch_02.jpg','','<br><br>hong kong residence<br>adrian mccarroll architects',603,78]; ImgAry[2]=['photos/architecture/arch_03.jpg','http://www.website.com','<br><br>silodam amsterdam<br>mvrdv',638,78]; ImgAry[3]=['photos/architecture/arch_04.jpg','http://www.website.com','<br><br>kings villa beijing',472,202]; ImgAry[4]=['photos/architecture/arch_05.jpg','http://www.website.com','<br><br>library hotel koh samui',517,145]; ImgAry[5]=['photos/architecture/arch_06.jpg','http://www.website.com','<br><br>shanghai airport <br>paul andreu architect',417,225]; ImgAry[6]=['photos/architecture/arch_07.jpg','http://www.website.com','<br><br>twin towers reception<br>mpi architects',472,202]; ImgAry[7]=['photos/architecture/arch_08.jpg','http://www.website.com','<br><br>china national offshore oil company<br>kohn pederson fox architects',543,57]; ImgAry[8]=['photos/architecture/arch_09.jpg','http://www.website.com','<br><br>quanta touyuan<br>artech architects',392,249]; ImgAry[9]=['photos/architecture/arch_10.jpg','http://www.website.com/beijing_olympic.php','<br><br>beijing olympic boom to view photos <a href="beijing_olympic.php" style="text-decoration:none; color:#cc0000"><b>click here</b></a>',110,242]; ImgAry[10]=['photos/architecture/arch_11.jpg','http://www.website.com','<br><br>walvis amsterdam<br>frits van dongen architecten cie',517,145]; ImgAry[11]=['photos/architecture/arch_12.jpg','http://www.website.com','<br><br>office and apartment buildings in the far east',110,337]; ImgAry[12]=['photos/architecture/arch_13.jpg','http://www.website.com','<br><br>bibliotheek amsterdam<br>jo coenen architecten',596,78]; ImgAry[13]=['photos/architecture/arch_14.jpg','http://www.website.com','<br><br>banciao model house taipei<br>kuo architects',229,243]; ImgAry[14]=['photos/architecture/arch_15.jpg','http://www.website.com','<br><br>commercial building<br>neihu ksarch',472,202]; ImgAry[15]=['photos/architecture/arch_16.jpg','http://www.website.com','<br><br>exhibition center melbourne<br>denton corker marshall',594,73]; ImgAry[16]=['photos/architecture/arch_17.jpg','http://www.website.com','<br><br>childrens palace guangzho china<br>steffan bradley architects',599,78]; ImgAry[17]=['photos/architecture/arch_18.jpg','http://www.website.com','<br><br>shiatze chen factory shanghai<br>layan design group',472,202]; ImgAry[18]=['photos/architecture/arch_19.jpg','http://www.website.com','<br><br>childrens palace guangzho china<br>steffan bradley architects',472,202]; ImgAry[19]=['photos/architecture/arch_20.jpg','http://www.website.com','<br><br>pukhet residence <br>adrian mccarroll architects',472,202]; for (var zxc0=0;zxc0<ImgAry.length;zxc0++){ ImgAry[zxc0][10]=new Image(); ImgAry[zxc0][10].src=Path+ImgAry[zxc0][0]; } // Functional Code var zxcTO; var ImgCnt=0; var zxcEvt=0; function zxcStyle(zxcele,zxcstyle,zxcp){ if (typeof(zxcele)=='string'){ zxcele=document.createElement(zxcele); } for (key in zxcstyle){ zxcele.style[key]=zxcstyle[key]; } if (zxcp){ zxcp.appendChild(zxcele); } return zxcele; } function zxcEventAdd(zxco,zxct,zxcf) { if ( zxco.addEventListener ){ zxco.addEventListener(zxct, function(e){ zxco[zxcf](e);}, false); } else if ( zxco.attachEvent ){ zxco.attachEvent('on'+zxct,function(e){ zxco[zxcf](e);}); } else { var zxcPrev=zxco["on" + zxct]; if (zxcPrev){ zxco['on'+zxct]=function(e){ zxcPrev(e); zxco[zxcf](e); }; } else { zxco['on'+zxct]=zxco[zxcf]; } } } function zxcAddEvent(zxc,zxcfun,zxcevt){ if (zxc.addEvent){ return; } zxc.addEvent=window[zxcfun]; zxcEventAdd(zxc,zxcevt,'addEvent'); } function zxcAddEvt(zxc,zxcfun,zxcevt){ zxc['zxcaddEvt'+zxcEvt]=window[zxcfun]; zxcEventAdd(zxc,zxcevt,'zxcaddEvt'+zxcEvt); zxcEvt++; } // parameters 0 = column pitch, 1 = row pitch, 2 = dot height, 3 = slide show button height function PlaceDots(zxccol,zxcrow,zxcdotheight,zxcssheight){ zxcnu=ImgAry.length; var zxcp=document.getElementById('dots'); zxcp.removeChild(zxcp.getElementsByTagName('DIV')[0]); var zxclft=0;zxctop=0; for (var zxc0=0;zxc0<zxcnu;zxc0++){ var zxcimg=zxcStyle('IMG',{position:'absolute',left:(Math.floor(zxc0%(zxcnu/2))*zxccol)+'px',top:(Math.floor(zxc0/(zxcnu/2))*zxcrow)+'px',cursor:(document.all)?'hand':'pointer'},zxcp); zxcimg.src=Path+'dots/dots'+(Math.floor(zxc0%(zxcnu/2))+1)+'.gif'; zxcAddEvt(zxcimg,'zxcDotMse','mouseover'); zxcAddEvt(zxcimg,'zxcDotMse','mouseout'); } zxcdimg=zxcStyle('IMG',{width:'43px',height:zxcssheight+'px',position:'absolute',left:(Math.ceil(zxcnu/2)*zxccol)+'px',top:((zxcrow+zxcdotheight-zxcssheight)/2)+'px'},zxcp); zxcdimg.src=Path+'dots/slidedot.gif'; zxcAddEvt(zxcdimg,'zxcStartSShow','mouseover'); zxcAddEvt(zxcdimg,'zxcStartSShow','mouseout'); zxcStyle(document.getElementById('Main'),{cursor:(document.all)?'hand':'pointer'}); } function zxcDotMse(zxcevt){ clearTimeout(zxcTO); var zxcdots=this.parentNode.getElementsByTagName('IMG'); for (var zxc0=0;zxc0<zxcdots.length;zxc0++){ if (zxcdots[zxc0]==this){ ImgCnt=zxc0; break; } } PlaceImage(); } function zxcStartSShow(zxcevt){ zxcevt.cancelBubble=true; if (zxcevt.stopPropagation) zxcevt.stopPropagation(); clearTimeout(zxcTO); if (zxcevt.type=='mouseover'){ this.src=Path+'dots/slidedotred.gif'; SlideShow(); } else { this.src=Path+'dots/slidedot.gif'; } } function SlideShow(){ PlaceImage(); ImgCnt=++ImgCnt%ImgAry.length; zxcTO=setTimeout('SlideShow()',3000); } function PlaceImage(){ var zxcimg=document.getElementById('Main') zxcStyle(zxcimg,{left:ImgAry[ImgCnt][3]+'px',top:ImgAry[ImgCnt][4]+'px'}); zxcimg.src=Path+ImgAry[ImgCnt][0]; document.getElementById('text').innerHTML=ImgAry[ImgCnt][2]; ResetDots(); } function ResetDots(){ var zxcimgs=document.getElementById('dots').getElementsByTagName('IMG'); var zxcmid=Math.ceil((zxcimgs.length-1)/2); for (var zxc0=0;zxc0<zxcimgs.length-1;zxc0++){ zxcimgs[zxc0].src=Path+'dots/dots'+((zxc0<zxcmid)?zxc0+1:zxc0-zxcmid+1)+'.gif'; } zxcimgs[ImgCnt].src=Path+'dots/dotred.gif'; } /*]]>*/ </script> <body > <div id="loading" style="position:absolute; left:895px;top:556px;"> <img src="../images/loading.gif" border=0 /></div> <a href="http://www.website.com"><img src="http://www.website.com/images/name_heading.gif" width="220" height="17" style="position:absolute;left:110px;top:74px;" border="0" /></a> <div id="text" style="position:absolute;left:110px;top:105px;width:320px;height:50px;text-Align:left;font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10px; color: #999999;text-decoration: none; line-height: 10pt;" ><br><br>seoul airport<br>terry farrell & partners</div> <div id="dots" style="position:absolute;left:110px;top:176px;" > <div style="font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 9px; color: #999999;"></div> </div > <img id="Main" src="http://www.website.com/images/photos/architecture/arch_01.jpg" style="position:absolute;left:229px;top:250px;" /> <img id="Main" src="http://www.website.com/images/horline.gif" width="857" style="position:absolute;left:110px;top:590px;" /> <script language="JavaScript" type="text/javascript"> /*<![CDATA[*/ // parameters 0 = column pitch, 1 = row pitch, 2 = dot height, 3 = slide show button height PlaceDots(22,20,17,44); /*]]>*/ </script>
|

02-26-08, 08:02 AM
|
|
Newbie Coder
|
|
Join Date: Feb 2007
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
anyone?
Pleeeeaaasssseeee....
|

02-27-08, 07:30 AM
|
|
Newbie Coder
|
|
Join Date: Feb 2008
Location: Nova Scotia, Canada
Posts: 53
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I would suggest installing firebug and stepping through your code. You can download firebug at: http://www.getfirebug.com/
|

02-28-08, 08:20 PM
|
|
Newbie Coder
|
|
Join Date: Feb 2007
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Firebug does not tell me there are any errors
|

02-28-08, 11:04 PM
|
|
Wannabe Coder
|
|
Join Date: Aug 2007
Location: Texas
Posts: 151
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I am having trouble following your variable names so maybe I am missing something but I don't see where you put any reference for the anchors. Where are the addresses? I don't see them in your array.
|

03-03-08, 05:55 AM
|
|
Newbie Coder
|
|
Join Date: Feb 2007
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
the addresses are: "http\\:www.website.com" in every array.
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|