HTML Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsWeb DesignHTML Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old June 1st, 2000, 10:04 PM
pR|Mo pR|Mo is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2000
Posts: 2 pR|Mo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I want a link to target a picture in a small frame, but if the picture doesn't exist, i want the link to change... Can someone help me!!!! PLEASE

------------------
pR|Mo

Reply With Quote
  #2  
Old June 2nd, 2000, 11:50 PM
rycamor rycamor is offline
Gödelian monster
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Jul 1999
Location: Pembroke Pines, Florida, USA
Posts: 2,300 rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 3 Days 3 h 2 m 4 sec
Reputation Power: 44
I don't think there's any way for Javascript to check for the existence of a file.

If you are able to use some server-side such as PHP or Perl, the answer is quite simple, as they provide methods of checking whether files exist.

Reply With Quote
  #3  
Old June 4th, 2000, 05:54 AM
rkmarcks rkmarcks is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2000
Posts: 81 rkmarcks User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 9
Send a message via AIM to rkmarcks
JavaScript can check for the existance of the file, but it is server side. It must be included between the <server></server> tags.

Then use File.exists() The File object only has two properties, constructor and prototype, but it has a myriad of methods. The 'exists' method is the one you're looking for.


If never done this before, but it should work assuming the server has JavaScript installed. Else try VBScript or Perl as mentioned before.

Reply With Quote
  #4  
Old June 5th, 2000, 02:44 AM
rycamor rycamor is offline
Gödelian monster
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Jul 1999
Location: Pembroke Pines, Florida, USA
Posts: 2,300 rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 3 Days 3 h 2 m 4 sec
Reputation Power: 44
Actually, I might have to eat my words. After browsing 'Pure Javascript' (SAMS Publishing) I found the following:

There is a properties of the image object called 'complete'

Also there is an 'onLoad' event and an 'onError' event.

I think perhaps the simplest use would be
<BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre><IMG name="myimage" src="yourfirstimage.jpg" onError="switchimage(identifier)">[/code]

switchimage() would be the name of your Javascript function to switch the 'src' attribute to "myimage", and "identifier" would be the parameter you pass to your function, so you can use it on several different images on your page, if need be.

(Bear in mind that I haven't had time to test any of this, but if you run into trouble, let me know, and I will try to help)

rmarks: yes if server-side Javascript is installed you are correct. However, that requires either Netscape Enterprise Server, or IIS running ASP. Javascript is occasionally installed on other webservers, but that number is extremely low.


[This message has been edited by rycamor (edited June 05, 2000).]

Reply With Quote
  #5  
Old June 5th, 2000, 07:06 AM
rkmarcks rkmarcks is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2000
Posts: 81 rkmarcks User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 9
Send a message via AIM to rkmarcks
I agree. I've always found it unfortunate that VBScript tends to be the default server side language while JavaScript is the default CLient Side language. Too bad they're not the same. But that's a philosophical arguement.

Your solution is a good one. I completely forgot about the onError event.

If a person does want to run server side script, I forgot to mention the <SERVER></SERVER> tages are only valid for Netscape. In IE you must use <script runat="server"></script> or the shorthand <% ...%>.

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignHTML Programming > Targeting pictures, but if they don't exist, target another one.


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway