473,569 Members | 2,845 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

tpgames
785 Contributor
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 1714
tpgames
785 Contributor
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 Recognized Expert Moderator MVP
Which line do you get an error on?
Jun 12 '07 #3
tpgames
785 Contributor
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 Contributor
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 Contributor
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
3272
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 link to the gif file. why? <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0"...
1
9684
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 the view link to update to point to the image representing that selection. So for example, if the list box held names of images I would want the...
15
4560
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 you.. Frances
14
2813
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 number) linking (and sometimes compiling) becomes immensely slow, and task manager shows that link.exe (or cl.exe) is barely using any processor time, but...
5
1888
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: http://digitalovertone.com/examples/iedisappear.html. I have stripped most of the irrelevant CSS from this page. Please observe: on loading the page,...
2
6952
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 header. I tried to put the link tag in the Master page, but the classes are not recognized in the Content Page. How do I use a StyleSheet with the...
2
1442
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 in the past. The style sheet includes such things as div#header. Is this correct? I thought it should be either div header or #header. I can't...
6
4467
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. The intention is to make the link clickable on both the play button and the video image. the page is http://www.0011.com/test/test_link.html ...
12
4004
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 time. The second may help me to know if an image has been downloaded and how many times. How to build such download link ? The informations...
0
7695
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7612
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7922
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8119
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7668
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7964
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5218
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3653
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
936
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.