# Modalbox öffnen beim onload

**URL:** <https://forum.shopware.com/t/modalbox-offnen-beim-onload/20854>\
**Category:** Shopware 3.5\
**Tags:** programming\
**Created:** [17. Juni 2014 um 16:48 UTC](https://forum.shopware.com/t/modalbox-offnen-beim-onload/20854 "2014-06-17T16:48:34Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jakko](https://avatars.discourse-cdn.com/v4/letter/j/51bf81/32.png) [@Jakko](https://forum.shopware.com/u/Jakko)\
**Post date:** [17. Juni 2014 um 16:48 UTC](https://forum.shopware.com/t/modalbox-offnen-beim-onload/20854/1 "2014-06-17T16:48:34Z")

</div>

Hallo, Ich bin dabei ein Plugin zu programmieren, mit der ein Modalbox geöffnet werden soll wenn die Seite (Hauptseite) fertiggeladen wird. Nur habe ich das bis jetzt nicht hinbekommen. Ich hoffe, dass mir jemand helfen kann… — Bootstrap.php — [code]\<?php class Shopware\_Plugins\_Frontend\_ModalBox\_Bootstrap extends Shopware\_Components\_Plugin\_Bootstrap  
{  
public function getLabel()  
{  
return ‘Modal Popup’;  
}

```
public function install()
{
    $this->subscribeEvent( 'Enlight\_Controller\_Action\_PostDispatch\_Frontend\_Index', 'onPostDispatchIndex' ); return true; } public function onPostDispatchIndex(Enlight\_Event\_EventArgs $arguments) { $view = $arguments-\>getSubject()-\>View(); $config = $this-\>Config(); if (empty($config-\>show) && $config-\>show !== null) { return; } $view-\>addTemplateDir($this-\>Path() . 'Views/'); $view-\>extendsTemplate('frontend/plugins/template/modalbox.tpl'); } } ?\> [/code] --- modalbox.tpl --- [code] {block name="frontend\_index\_header\_javascript" append} <script type="text/javascript" src="%7Blink%20file='frontend/plugins/template/js/popupModal.js'%7D"> </script>{/block} {block name="frontend\_index\_header\_css\_screen" append} <link type="text/css" media="all" rel="stylesheet" href="%7Blink%20file='frontend/plugins/template/css/index_modal.css'%7D">{/block}

```

{\* Heading \*}

## Titel

{s name=“ModalCloseIcon”}×{/s}

## {s name=“IndexModalHeader”}Willkommen auf unserer Seite{/s}

[/code] — popupModal.js — ` $(document).ready(function() { $('#my\_modalBox').show(); }); `

---

<div class="post-metadata">

**Author:** ![brettvormkopp](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/brettvormkopp/32/7788_2.png) [@brettvormkopp](https://forum.shopware.com/u/brettvormkopp)\
**Post date:** [17. Juni 2014 um 22:19 UTC](https://forum.shopware.com/t/modalbox-offnen-beim-onload/20854/2 "2014-06-17T22:19:21Z")

</div>

Wird der der Inhalt aus modalbox.tpl geladen?

---

<div class="post-metadata">

**Author:** ![Jakko](https://avatars.discourse-cdn.com/v4/letter/j/51bf81/32.png) [@Jakko](https://forum.shopware.com/u/Jakko)\
**Post date:** [17. Juni 2014 um 23:06 UTC](https://forum.shopware.com/t/modalbox-offnen-beim-onload/20854/3 "2014-06-17T23:06:42Z")

</div>

Ja genau…

---

<div class="post-metadata">

**Author:** ![brettvormkopp](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/brettvormkopp/32/7788_2.png) [@brettvormkopp](https://forum.shopware.com/u/brettvormkopp)\
**Post date:** [18. Juni 2014 um 01:08 UTC](https://forum.shopware.com/t/modalbox-offnen-beim-onload/20854/4 "2014-06-18T01:08:05Z")

</div>

Wie auch immer der komplette Inhalt des tpl’s geladen wird, möglichweise ist das Javascript früher geladen als das tpl? Gibt es eine Beispielseite?

---

<div class="post-metadata">

**Author:** ![Jakko](https://avatars.discourse-cdn.com/v4/letter/j/51bf81/32.png) [@Jakko](https://forum.shopware.com/u/Jakko)\
**Post date:** [18. Juni 2014 um 12:09 UTC](https://forum.shopware.com/t/modalbox-offnen-beim-onload/20854/5 "2014-06-18T12:09:04Z")

</div>

Ich habs mit (window).load probiert, da klappt es aber auch nicht. Eigentlich müsste er doch die JavaScript erst nach dem kompletten Laden der Seite ausführen. Oder? [code] (window).load(function() { $(’#my\_modalBox’).show(); }); [/code]

---

<div class="post-metadata">

**Author:** ![EikeBrandtWarneke](https://avatars.discourse-cdn.com/v4/letter/e/cdc98d/32.png) [@EikeBrandtWarneke](https://forum.shopware.com/u/EikeBrandtWarneke)\
**Post date:** [18. Juni 2014 um 12:30 UTC](https://forum.shopware.com/t/modalbox-offnen-beim-onload/20854/6 "2014-06-18T12:30:29Z")

</div>

Ansonsten erzeuge die modal box so: ` $(window).load(function() { var div = $( "#my\_modalBox" ).html(); var config = { width: "200px" }: $.modal( div, "Überschrift", config ); }); ` Viele Grüße
