11548 sujets

JavaScript, DOM et API Web HTML5

Bonjour à tous,

Bon je vais aller très vite car pour la plupart d'entre vous, vous allez vite comprendre et si ça se trouve me dépanner de suite.... Smiley biggrin

J'ai fais une petite fonction javascript qui permet de centrer une popup (jusque là, rien de bien sorcier).
Sous Firefox, ça fonctionne super bien, mais sous IE, ça ne m'ouvre pas de popup, et je n'ai pas d'erreur javascript détectée !!! Smiley biggol

Je vais vous donner le code de ma fonction.
Sinon, comme je l'appelle d'une page générée avec du PHP, j'insère le nom du fichier à ouvrir via cette variable...

Voilà ma fonction Javascript :

function popupCentree(sAdresseFichier, sNomFenetre, iLargeur, iHauteur, sOptions){
    //On définit la largeur de la popup
    var iLargeurPopup = (screen.width - iLargeur) / 2;

    //On définit la hauteur de la popup
    var iHauteurPopup = (screen.height - iHauteur) / 2;

    //On définit les options de la popup
    if (sOptions == ""){
        //Si aucune option n'a été définie, on en met par défaut
        sLesOptions = 'toolbar=no, menubar=no, location=no, directories=no, status=no, resizeable=no, scrollbars=yes';
    }
    else{
        sLesOptions = sOptions;
    }

    //On génère la popup
    window.open(sAdresseFichier, sNomFenetre, 'height=' + iHauteur + ', width=' + iLargeur + ', top=' + iHauteurPopup + ', left=' + iLargeurPopup + ', ' + sLesOptions);
}


Voilà comment je l'appelle :

echo "<a href=\"".$sRacineSite."/admin/media/fiche.php?fiche=".$iBDDIdMedia."\ onclick=\"popupCentree('".$sRacineSite."/admin/media/fiche.php?fiche=".$iBDDIdMedia."','".$sLang_TitrePopupFicheDetaillee."', 720, 700, '');return false;\">Ma Popup centrée</a> \n";

où $sRacineSite = "../.." et $iBDDIdMedia = Numéro de ma fiche

Ce qui correspond dans le code de la page "parent" à :

<a href="../../admin/media/fiche.php?fiche=49" onclick="popupCentree('../../admin/media/fiche.php?fiche=49','Fiche détaillée', 700, 600, '');return false;">Ma Popup centrée</a>


Si vous pouviez me dépanner.... car moi je ne vois plus...
Merci d'avance pour vos réponses. Smiley smile
Modifié par Eagle2000 (09 Jun 2006 - 19:30)
up

j'ai exactement le même pb depuis quelques jours.par contre, il me dit que le chemin n'est pas trouvé, alors que tout les autres l'ouvre sans pbs.un up au cas où.
Salut Keran,

Alors au fait et pour info, j'ai trouvé la solution il y a quelques minutes...

Le truc débile de base !!!!!

En fait, dans le nom de ma popup, j'utilisais un espace ;
En effet, ma variable $sLang_TitrePopupFicheDetaillee valait :
$sLang_TitrePopupFicheDetaillee = "Ma Popup";


et je l'ai remplacé par :
$sLang_TitrePopupFicheDetaillee = "Ma_Popup";


Depuis, tout est rentré dans l'ordre et ça fonctionne nickel... Smiley biggrin

Pour ma part c'est donc résolu.
Merci encore.
salut

je vais voir de ce côté.merci.mais je crois que le pb n'est pas aussi simple.j'utilise la même fonction depuis trois ans, je n'ai jamais eu de pbs et avec firefox, la console n'affiche aucune erreur, j'utilise la webdevelloper.en plus, un jour çà marche et le lendemain plus rien avec un nom sans espace.
le pb est là, je crois.

Browser Window Restrictions
Does your Web site position windows so that the title bar or address bar is above the visible top of the display, or the status bar is below the visible bottom of the display?
Review your code to ensure you understand the restrictions now in place for script-initiated windows using the window.open() or window.createPopup() methods. The script can call the same methods for the creation of an Internet Explorer window with chrome (using the window.open() method) or an Internet Explorer chromeless pop-up window (using the window.createPopup() method). However, the design might need to be reviewed to ensure that pop-up windows are appropriately visible to the user and that the status bar contains accurate information.

The following are guidelines for working with script-initiated window calls in a process running the Windows Restrictions Security feature.

For windows opened using window.open():

Expect the status bar to be present, and code for it. The status bar will be on by default and is 20-25 pixels in height.
Adjust your window's size and content so that it will fit well visually with the window's overall size. The window will not cover the taskbar, so it might lose 40 pixels if the status bar is on and the taskbar is not accounted for. Vertically size the window no more than 30 pixels outside the taskbar.
Do not open windows off-screen—they will be moved by the smallest offset of X and Y coordinates that allows the window to fully display on-screen.
As before, the display of the window will be affected by the display theme, font size, and resolution, so you might also need to account for these UI influences when you are designing your windows.
Note: window.open() with fullscreen=yes will now result in a maximized window, not a kiosk mode window.
For windows opened using window.createPopup():

Adjust the window's size and content so it will fit well visually with the window's overall size. With this new feature, the window will not cover its parent window's title bar or status bar, so it might lose 40 pixels if the title and status bars are not accounted for. Vertically size the window no larger than the currently visible area of the page.
Do not open chromeless windows outside the HTML rendering surface of Internet Explorer—they will be moved by the smallest offset of X and Y coordinates that allows the window to be fully displayed inside the client area. There is one exception: up to half of the window can exist outside the left or right edge of the Internet Explorer client area.
As before, the display of the window will be affected by the display theme, font size, and resolution, so you might also need to account for these UI influences when you are designing your windows.
Merci Keran,

Effectivement très intéressant.
Je ne savais pas tout ça ... !!!

Je vais me pencher sur la chose.
Smiley smile