corsasport.co.uk
 

Corsa Sport » Message Board » Off Day » Geek Day » Javascript Question 2


New Topic

New Poll
  Subscribe | Add to Favourites

You are not logged in and may not post or reply to messages. Please log in or create a new account or mail us about fixing an existing one - register@corsasport.co.uk

There are also many more features available when you are logged in such as private messages, buddy list, location services, post search and more.


Author Javascript Question 2
Steve
Premium Member

Avatar

Registered: 30th Mar 02
Location: Worcestershire Drives: Defender
User status: Offline
29th Apr 07 at 15:12   View Garage View User's Profile U2U Member Reply With Quote

Hi another question, I have the following code

code:
<img src="{URL}" alt="Image Resized, click to view full image" title="Image Resized, click to view full image" border="0" onload="if(this.width > 500){this.width=(500); this.className='clickable';}" onMouseover="if(this.width >= 500) {document.body.style.cursor = 'pointer'}" onMouseout="document.body.style.cursor = 'default'" onclick="if(this.width >= 500) { window.open('{URL}', '_blank'); return false; }"/>


Which resizes images if they are greater than 500 in width, now how would i add some html to the end of this statement that only displays if the image is resized, or to put it another way, greater than 500 wide??

i imagine i need to put something in this IF statement

code:
onload="if(this.width > 500){this.width=(500); this.className='clickable';}"


but am unsure how to make it display some html or text if this is true

To put it another way, if it resizes and image, add a bit of text to the bottom of the image

[Edited on 29-04-2007 by Steve]
Steve
Premium Member

Avatar

Registered: 30th Mar 02
Location: Worcestershire Drives: Defender
User status: Offline
29th Apr 07 at 15:19   View Garage View User's Profile U2U Member Reply With Quote

if i could pass a value in the IF statement that i could pick up just after using a document.write that would work ie

code:
onload="if(this.width > 500){this.width=(500); this.className='clickable'; var text='TEST';}"


then after it all put

code:
<script language="JavaScript" type="text/javascript">
document.write(text);
</script>


but if i do that it doesnt seem to put anything into the text variable?? just says undefined

 
New Topic

New Poll

  Related Threads Author Forum Replies Views Last Post
trying to find an image Simon Geek Day 1 543
21st Apr 06 at 19:26
by Ian
 
After Constructice Criticism Bart Geek Day 41 2323
5th Sep 06 at 08:33
by James
 
Javascript or Macromedia Kif Geek Day 5 706
18th Jan 07 at 11:48
by Cybermonkey
 
bit of coding for a webpage Tantastic Geek Day 4 678
22nd Feb 07 at 23:31
by Tantastic
 
Javascript people Steve Geek Day 0 642
28th Apr 07 at 19:07
by Steve
 

Corsa Sport » Message Board » Off Day » Geek Day » Javascript Question 2 28 database queries in 0.0115209 seconds