SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Evangelist stef25's Avatar
    Join Date
    Nov 2004
    Location
    belgium
    Posts
    465
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    return false not working

    any idea why this wouldnt work? it still jumps to # at the top of the page. there is some external javascript that triggers an action when the link is clicked. seems so simple but yet doesnt work ...

    echo "<a href='#' id='showImageValues2' onclick='return false'>Add another image</a>";
    I need someone to protect me from
    all the measures they take in order to protect me

  2. #2
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,014
    Mentioned
    187 Post(s)
    Tagged
    2 Thread(s)

    href

    The href value "#" points the link to "self" (the page), so that's where the browser goes when the link is clicked.

  3. #3
    SitePoint Evangelist stef25's Avatar
    Join Date
    Nov 2004
    Location
    belgium
    Posts
    465
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yeah but is this not stopped by return false?
    I need someone to protect me from
    all the measures they take in order to protect me

  4. #4
    SitePoint Enthusiast
    Join Date
    Nov 2006
    Posts
    99
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't know which browser are you using but in IE6&7, Mozilla and Opera it doesn't jump to top...
    But still as alternative you can use
    Code HTML4Strict:
    <a href='javascript:void(0)' id='showImageValues2'>Add another image</a>
    to disable link.

  5. #5
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,014
    Mentioned
    187 Post(s)
    Tagged
    2 Thread(s)

    link

    Why use a link that isn't a link anyway? Maybe a button or a styled span would be more appropriate.

  6. #6
    SitePoint Evangelist stef25's Avatar
    Join Date
    Nov 2004
    Location
    belgium
    Posts
    465
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok ill go for a styled span, good idea
    I need someone to protect me from
    all the measures they take in order to protect me

  7. #7
    rajug.replace('Raju Gautam'); bronze trophy Raju Gautam's Avatar
    Join Date
    Oct 2006
    Location
    Kathmandu, Nepal
    Posts
    4,013
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Why not like this?
    Code:
    <script language="javascript">
    function hello(){
    	var a = 1;
    	if(a == 1){
    		alert('Yes go to another page');
    		document.location='mextpage.php';
    		return true;
    	}else{
    		alert('Sorry! Invalid Click!');
    		return true;
    	}
    }
    </script>
    PHP Code:
    <?php
    echo "<a href=\"javascript:void(null);\" id=\"showImageValues2\" onclick=\"return hello();\">Add another image</a>";
    ?>
    Mistakes are proof that you are trying.....
    ------------------------------------------------------------------------
    PSD to HTML - SlicingArt.com | Personal Blog | ZCE - PHP 5


Bookmarks

Posting Permissions

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