SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot
    Join Date
    Dec 2000
    Location
    Grosseto, Italy
    Posts
    189
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    short code: IE browser compatibility

    Code:
    <script language="javascript">
    <!--
    function askDelete(id){
    if(confirm("Are you sure?" )){
    	 window.self.location.href("/delete-link.asp?id=" + id)
    }
    }
    //-->
    </script>
    the function is then called in the body like this
    Code:
    <a href="#" onclick="askDelete('15'); return false;"><img href="/images/delete.png" border="0" alt="delete"></a>
    now, someone told me that this code doesn't work in some coomon browser versions. Even IE 5.5

    is this true? if yes, how can I arrange it to work it in the most common browsers and browser's versions?

    Thanks

  2. #2
    Web-coding NINJA! silver trophy beetle's Avatar
    Join Date
    Jul 2002
    Location
    Dallas, TX
    Posts
    2,900
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The problem is with this line....
    Code:
     window.self.location.href("/delete-link.asp?id=" + id)
    Should be
    Code:
     location.href = "/delete-link.asp?id=" + id;
    However, I'd do this completely differently
    Code:
    function confirmDelete()
    {
    	return confirm( "Are you sure?" );
    }
     
    <a href="/delete-link.asp?id=15" onclick="return confirmDelete()">...</a>
    beetle a.k.a. Peter Bailey
    blogs: php | prophp | security | design | zen | software
    refs: dhtml | gecko | prototype | phpdocs | unicode | charsets
    tools: ide | ftp | regex | ffdev




  3. #3
    SitePoint Zealot
    Join Date
    Dec 2000
    Location
    Grosseto, Italy
    Posts
    189
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thank you very much for the indications!


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
  •