< a href # - Gegenmittel?!

  • Hallo, ich verwende auf meiner HP ein Script zum Fotoöffnen, das mit <a href="#" beginnt.

    Das Script öffnet das Foto nach Wunsch, aber das <a href="#" lädt die Seite neu bzw. bringt mich an die top-Position.

    Nachdem die Seite lang ist, ist diese Automatisch-Nach-Oben lästig. :mad: und wenn ich am <a href="#" rumbastle, funktioniert nichts mehr...

    zum selbst ansehen: http://www.igorloro.net >> news Danke!

    hier noch das vollständige script:

    im header:

    <script type="text/javascript">
    <!--
    function OpenFoto(img){
    foto= new Image();
    foto.src=(img);
    ControlFoto(img);
    }
    function ControlFoto(img){
    if((foto.width!=0)&&(foto.height!=0)){
    ViewFoto(img);
    }
    else{
    interval_a="ControlFoto('"+img+"')";
    interval_b=setTimeout(interval_a,20);
    }
    }
    function ViewFoto(img){
    width=foto.width+20;
    height=foto.height+24;
    try {
    if (output.closed == false) throw "offen";
    }
    catch (e) {
    if (e=="offen") {
    output.close();
    }
    }
    output=window.open("","output","left=40,top=40,width="+width+",height="+height+",location=no,toolbar=no,menubar=no,status=no,scrol lbars=no,resizable=no");
    output.document.writeln("<html><head><title>..:: Foto ::..<\/title><\/head>");
    output.document.writeln("<body bgcolor=\"white\" text=\"white\" link=\"white\" vlink=\"white\" alink=\"white\" leftmargin=\"0\" marginwidth=\"0\" topmargin=\"0\" marginheight=\"0\">");
    output.document.writeln("<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" height=\"100%\">");
    output.document.writeln("<tr><td width=\"100%\" height=\"100%\" align=\"left\" valign=\"top\"><p><a href=\"javascript:self.close()\"><img src=\""+img+"\" width=\""+foto.width+"\" height=\""+foto.height+"\" border=\"10\" alt=\"click here to close the window\"></a><\/p><\/td><\/tr>");
    output.document.writeln("<\/table><\/body><\/html>");
    output.document.close();
    output.focus();
    }

    // -->
    </script>  
    und im body

    <a href="#" onclick="OpenFoto('bild.jpg')"> <img src="bildminiatur.jpg" alt="click for zoom" border="0">

    Einmal editiert, zuletzt von igorloro (18. März 2010 um 17:39)

  • Alternative:

    Code
    <a href="alternatives_linkziel.html" onclick="OpenFoto('bild.jpg');return false;">blubb</a>

    So kann man auch Usern ohne JavaScript eine extra Seite anbieten.