473,408 Members | 2,813 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

Confused on how to get link to image correct in this code.

tpgames
785 512MB
I have my images at a different site, and wanted the game to access those images. I've changed the links in the other parts of the code, but still get a undefined error, and thought that the below code has the image links wrong, because I didn't add a URL to the code. I'm not sure how to add the URL. Thanks

Here's the specific src codes:
Expand|Select|Wrap|Line Numbers
  1. <img src="'+cardbg.src+'" width=120 height=140 alt="" name="k'+i+'" border=0>
  2.  
  3. <img src="'+ima_a[i].src+'" width=120 height=140 alt="" name="s'+i+'" border=0>
  4.  
  5. <img src="'+ima_a[i].src+'" width=120 height=140 alt="" name="s'+(i+4)+'" border=0>
Here is the code in its context:
Expand|Select|Wrap|Line Numbers
  1. <img src="'+cardbg.src+'" width=120 height=140 alt="" name="k'+i+'" border=0></a></div>';
  2.   }  
  3.   document.writeln(temp);   
  4. }
  5.  
  6. function block2()
  7. { var temp='';
  8.   for (var i=0; i<4; i++) 
  9.   { temp=temp+'<div id="s_'+i+'" style="position:absolute; top:'+(yoff+i*dy)+'px; left:'+xoff_s+'px; width:'+dx+'px; height:'+dy+'px; zIndex:0">';
  10.     temp=temp+'<a href="javascript:ablage('+i+')"><img src="'+ima_a[i].src+'" width=120 height=140 alt="" name="s'+i+'" border=0></a></div>';
  11.     temp=temp+'<div id="s_'+(i+4)+'" style="position:absolute; top:'+(yoff+i*dy)+'px; left:'+(xoff_s+dx)+'px; width:'+dx+'px; height:'+dy+'px; zIndex:0">';
  12.     temp=temp+'<a href="javascript:ablage('+(i+4)+')"><img src="'+ima_a[i].src+'" width=120 height=140 alt="" name="s'+(i+4)+'" border=0></a></div>';
And here is the beginning part of the code, where the URL has been defined:
Expand|Select|Wrap|Line Numbers
  1. var leer=new Image;   leer.src='leer.gif';     
  2. var cardbg=new Image; cardbg.src='cardbg.gif'; 
  3. var ima_c =new Array();
  4. var ima_ca=new Array();
  5. var ima_a =new Array();
  6. for (i=0; i<52; i++)
  7. { ima_c[i] =new Image(); ima_c[i].src='c'+i+'.gif'; 
  8.   ima_ca[i]=new Image(); ima_ca[i].src='c'+i+'a'+'.gif'; 
  9. }
  10. for (i=0; i<4; i++) { ima_a[i]=new Image(); ima_a[i].src='a'+i+'.gif'; }
Its a 9 Patience type game. Thanks!
Jun 11 '07 #1
5 1706
tpgames
785 512MB
Wrong Beginning Code!
Here is the CORRECT code with the URL's defined:
Expand|Select|Wrap|Line Numbers
  1. <!-- Code copyrighted by Ujas at Gamecraft.de -->
  2.  
  3. <script language="Javascript" src="http://www.tpgames.net/gaming/2/cards/js/b.js"></script>
  4. <script language="javascript">
  5.  
  6. zmax=104,rmax=9,kmax=4,smax=8,dx=120,dy=140,dy2=12,xoff=12,yoff=64,xoff_s=xoff+rmax*dx+8, xoff_t=xoff_s+2*dx+8;
  7. var count,index,i,gewaehlt,x_alt;
  8. var karte=new Array(zmax); 
  9. var stack=new Array(8);    
  10. var karten_pro_spalte=new Array(rmax);
  11. var f=new Array(rmax*zmax);
  12. var liste=new Array(zmax);
  13. var xyz=new Array(3);
  14.  
  15. // ----- Bilder vorladen: --------------------------------------------------------------
  16.  
  17. var leer=new Image;   leer.src='http://i107.photobucket.com/albums/m287/tpkyteroo/zgames/cards/tos1/null.jpg';     
  18. var cardbg=new Image; cardbg.src='http://i107.photobucket.com/albums/m287/tpkyteroo/zgames/cards/tos1/cardbg.jpg'; 
  19. var ima_c =new Array();
  20. var ima_ca=new Array();
  21. var ima_a =new Array();
  22. for (i=0; i<52; i++)
  23. { ima_c[i] =new Image(); ima_c[i].src='http://i107.photobucket.com/albums/m287/tpkyteroo/zgames/cards/tos1/c'+i+'.jpg'; 
  24.   ima_ca[i]=new Image(); ima_ca[i].src='http://i107.photobucket.com/albums/m287/tpkyteroo/zgames/cards/tos1/c'+i+'a'+'.jpg'; 
  25. }
  26. for (i=0; i<4; i++) { ima_a[i]=new Image(); ima_a[i].src='http://i107.photobucket.com/albums/m287/tpkyteroo/zgames/cards/tos1/a'+i+'.jpg'; }
  27.  
Jun 11 '07 #2
acoder
16,027 Expert Mod 8TB
Which line do you get an error on?
Jun 12 '07 #3
tpgames
785 512MB
According to the JavaScript console, there is no error.
I just get a card undefined when I push 'deal to rows' button or 'new draw'.

The only thing I thought I was doing differently from the original script was having the images hosted at a different site, rather than have them in the same folder as the file. I wasn't aware that I had inadvertently changed anything else in the code.

Here's the link to the game:
9 solitaire

I'm going to upload the images to the same folder and upload the original script and see what gives. I'll post a result in a few. Thanks!
Jun 12 '07 #4
tpgames
785 512MB
Okay, I didn't realize that my javascript console was changed to not auto give errors. After I clicked on show errors, I receive this from my version of the game:
too much recursion line 146 of b.js
my_obj has no properties line 134 of b.js

I also realized, that I had moved the html links to a different location. The only other change I had made was making the cards larger.

However, the cards never deal, New Game doesn't show me cards dealt on my version of game. And, I'm wondering when JS will start making sense to me. LOL



Here is the link to the Original script:
Original Script

Original b.js
b.js

I am now more confused then before. What I thought was wrong, I'm not seeing as not wrong. Thanks!
Jun 12 '07 #5
tpgames
785 512MB
I figured out that when I don't have 2 div tags in, the game doesn't work.

So, I've solved the issue. Thanks!
Jun 12 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: j erickson | last post by:
with the following xsl and xml file, the display of the gif file with the <image/url> tag works. However, the gif file in the <description> tag using the name attribute "src" won't make the correct...
1
by: John Doe | last post by:
I have a PHP page that generates a list box with several options in it. I would like to have a "view" link next to the list box. When the user changes the contents of the list box, I would like...
15
by: Frances Del Rio | last post by:
I have a bunch of Photoshop images on my server, I want when user clicks on a link to a Photoshop img for it to start downloading (like when you click on a Word file..) how can I do that? thank...
14
by: Steve McLellan | last post by:
Hi, Sorry to repost, but this is becoming aggravating, and causing me a lot of wasted time. I've got a reasonably large mixed C++ project, and after a number of builds (but not a constant...
5
by: kjmatthews | last post by:
I am designing a site but only have access to a Mac, equipped with Virtual PC. On IE6 is appears that, on some pages of this site, the navigation does not appear. I have put up a test case:...
2
by: SR | last post by:
I have started a web site using ASP.NET 2.0. I would like to centralize all of my classes in a StyleSheet but I cannot figure out how to link the StyleSheet to a Content Page since there is no...
2
by: wavedancer | last post by:
I am confused about the syntax used in the style sheet that accompanies the website I've inherited and have been asked to tidy up. XHTML is new to me, and I've only used CSS for font and link styles...
6
by: liketofindoutwhy | last post by:
There is a link that encloses a span (or a div), but the link won't work in IE 7 (clicking on video image works, but not on the play button), while it works well in Firefox 2 and 3, and Safari 3....
12
by: Bob Bedford | last post by:
I've to build a website where the customer can buy an image. I'm thinking in the 2 ways to let people get those images: receive them by Email or send them an image link wich validity is limited in...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.