2010-01-28 4 views

Répondre

139
<a href="/index2.php?option=com_jumi&amp;fileid=3&amp;Itemid=11" 
    onclick="window.open(this.href,'targetWindow', 
            'toolbar=no, 
            location=no, 
            status=no, 
            menubar=no, 
            scrollbars=yes, 
            resizable=yes, 
            width=SomeSize, 
            height=SomeSize'); 
return false;">Popup link</a> 

Où largeur et hauteur sont des pixels.

+0

facile et direct! – programmer

+13

Vous devrez également échanger le dernier caractère ")" pour "); return false;" pour empêcher l'ouverture du lien d'origine en plus de la fenêtre contextuelle. – Andrew

+2

Un ancien mais je l'ai trouvé via la recherche donc la réponse corrigée comme par réponse de @AndrewSpear – neil

12

Ajoutez-les simplement à la chaîne de paramètres.

window.open(this.href,'targetWindow','toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=350,height=250') 
16
window.open('http://somelocation.com','mywin','width=500,height=500'); 
+0

a bien fonctionné, merci –

3

Ce sont les meilleures pratiques de Mozilla Developer Network's window.open page:

<script type="text/javascript"> 
var windowObjectReference = null; // global variable 

function openFFPromotionPopup() { 
    if(windowObjectReference == null || windowObjectReference.closed) 
    /* if the pointer to the window object in memory does not exist 
    or if such pointer exists but the window was closed */ 

    { 
    windowObjectReference = window.open("http://www.spreadfirefox.com/", 
    "PromoteFirefoxWindowName", "resizable,scrollbars,status"); 
    /* then create it. The new window will be created and 
     will be brought on top of any other window. */ 
    } 
    else 
    { 
    windowObjectReference.focus(); 
    /* else the window reference must exist and the window 
     is not closed; therefore, we can bring it back on top of any other 
     window with the focus() method. There would be no need to re-create 
     the window or to reload the referenced resource. */ 
    }; 
} 
</script> 

<p><a 
href="http://www.spreadfirefox.com/" 
target="PromoteFirefoxWindowName" 
onclick="openFFPromotionPopup(); return false;" 
title="This link will create a new window or will re-use an already opened one" 
>Promote Firefox adoption</a></p> 
9
<a style="cursor:pointer" 
    onclick=" window.open('http://YOUR.URL.TARGET','',' scrollbars=yes,menubar=no,width=500, resizable=yes,toolbar=no,location=no,status=no')">Your text</a> 
+0

Bien que je demande, qu'est-ce que cela ajoute à toutes les réponses déjà données? – EWit

+0

Ceci est celui qui fonctionne, au-dessus de ceux qui ne fonctionnent pas ... – user1735921

Questions connexes