Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Aug 2006
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Javascript in onload

    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 an image, put a bit of text or html underneath the image saying this is the case

  • #2
    New to the CF scene
    Join Date
    Aug 2006
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •