sciactive / pnotify

Beautiful JavaScript notifications with Web Notifications support.
https://sciactive.com/pnotify/
Apache License 2.0
3.65k stars 514 forks source link

Adding to frameset? #382

Closed exetico closed 4 years ago

exetico commented 4 years ago

Hi

I'm trying to use pnotify on a page, where i only have a frameset. There's no option to add a body, so i need to find a work-around.

I can see that i'm able to define target, however, i'm unsure about how i should use it.

TL;DR: Can i use pnotify, in a page where i only have a frameset, and frames - and no body?

exetico commented 4 years ago

I'm able to add content to the page with $('<p>Testcontent</p>').insertBefore('frameset') - but i'm not sure, how i can get PNotify to work.

I've also tried to define target as frames['mainframename'].document.body, but it's still adding the html to html > frameset (in the bottom of it).

<div class="
      ui-pnotify
      ui-pnotify-with-icon

      ui-pnotify-in ui-pnotify-fade-in

      ui-pnotify-fade-normal

    " aria-live="assertive" role="alertdialog" ui-pnotify="true" style="right: 25px; bottom: 25px;"><div class="
        ui-pnotify-container
        brighttheme
        brighttheme-success

        ui-pnotify-shadow
      " role="alert" style="width: 360px; min-height: 16px;">
    <div class="ui-pnotify-icon "><span class="brighttheme-icon-success"></span></div>
    <h4 class="ui-pnotify-title ">Test</h4>
    <div class="ui-pnotify-text " role="alert">I'm ready.... .</div>
    <!----><!----><!----></div></div>
exetico commented 4 years ago

I actually managed to add a body-dom to the page, with the following code:

    var customBody = document.createElement('body');
    customBody.id = "customBody";
    $(customBody).insertBefore('frameset');

And that's working with PNotify.

But i would like to target my frame, if possible - or, another element within my html, before the frameset.

hperrin commented 4 years ago

You can change the context of a stack. As long as PNotify can add elements to that context, it should work.

To change the default stack context use

PNotify.defaultStack.context = someElementOrDocumentBody;

If your frame is on the same origin, I believe you should have access to its document body.

hperrin commented 4 years ago

You should change the stack context before creating any notices.

exetico commented 4 years ago

I'll do that, and see how it goes. Thanks!