J'essaie de charger un href dans une fenêtre contextuelle de dimensions spécifiques qui se concentre également sur l'écran.
Voici ma source:
<li> <a class="sprite_stumbleupon" href="http://www.stumbleupon.com/submit?url=http://www.your_web_page_url" target="_blank" onclick="return windowpop(545, 433)"></a> </li>
Et voici mon javascript:
function windowpop(url, width, height) { var leftPosition, topPosition; //Allow for borders. leftPosition = (window.screen.width / 2) - ((width / 2) + 10); //Allow for title and status bars. topPosition = (window.screen.height / 2) - ((height / 2) + 50); //Open the window. window.open(url, "Window2", "status=no,height=" + height + ",width=" + width + ",resizable=yes,left=" + leftPosition + ",top=" + topPosition + ",screenX=" + leftPosition + ",screenY=" + topPosition + ",toolbar=no,menubar=no,scrollbars=no,location=no,directories=no"); }
Cela semble renvoyer une erreur 404 lors de la vérification. Qu'est-ce que je fais mal?
Merci beaucoup.
function windowpop(url, width, height)
La fonction nécessite une URL qui lui sera renvoyée.
onclick="return windowpop(545, 433)"
Vous ne retournez que la width
et la height
.
Essayez de renvoyer l'URL à l'aide de this.href
:
onclick="return windowpop(this.href, 545, 433)"
Exemple: http://jsfiddle.net/zKKAM/1/