Explore the community Forums Lectora Lectora Questions & Answers onbeforeunload and seamless

Tagged: 

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #345298 Score: 0
    Profile photo of approg
    approg
    Member
    beginner
    intermediate
    curious george
    wise owl
    contributor
    friend finder
    picture perfect
    10 pts
    @approg

    With Lectora 16 I can listen for the unbeforeunload event with this JavaScript

    window.addEventListener(“beforeunload”, blah);

    This doesn’t work in Lectora 17 with seamless activated because it’s now using iframes. How can I listen for an onbeforeunload or onunload event in Lectora 17 with seamless activated?

    #345312 Score: 1
    Profile photo of Sergey Snegirev
    Sergey Snegirev
    Member
    contributor
    intermediate
    advanced
    friend finder
    lab member
    junior moderator
    advocate
    LUC16
    LUC16 Attendee
    wise owl
    337 pts
    @ssneg

    Try replacing window with parent.window for seamless.

    This post has received 1 vote up.
    #345471 Score: 0
    Profile photo of approg
    approg
    Member
    beginner
    intermediate
    curious george
    wise owl
    contributor
    friend finder
    picture perfect
    10 pts
    @approg

    Sorry, I don’t mean when the title window is closed but when the user moves from one page in the title to another page in the title. I used to be able to track that using

    window.addEventListener(“beforeunload”, blah);

    #345483 Score: 0
    Profile photo of Sergey Snegirev
    Sergey Snegirev
    Member
    contributor
    intermediate
    advanced
    friend finder
    lab member
    junior moderator
    advocate
    LUC16
    LUC16 Attendee
    wise owl
    337 pts
    @ssneg

    What I wrote above has nothing to do with closing windows. Did you try what I suggested?

    #345565 Score: 0
    Profile photo of approg
    approg
    Member
    beginner
    intermediate
    curious george
    wise owl
    contributor
    friend finder
    picture perfect
    10 pts
    @approg

    Yes I have tried what you suggested and with Chrome, Firefox, and Edge the event is only triggered when the window is closed and not when the page changes.

    I think my original question was unclear 🙁

    When seamless is off Lectora unloads the current page to load the next page. I can “know” when this unloading occurs by listening for the event window.addEventListener(“beforeunload”, blah); With seamless on the pages are changed in a way that does not trigger an onbeforeunload event and I’m wondering what events are triggered.

    #345598 Score: 1
    Profile photo of Johnattan Barona
    Johnattan Barona
    Member
    beginner
    intermediate
    wise owl
    1 pt
    @jbarona9656

    With Seamless activated some normal javascript functions will not work, we have provided helper functions in our publish code that will work in Seamless publishing and non-Seamless cases.  The functions are:

    getDisplayWindow()
    Returns the window objects that is to be used for dealing with the js objects generated by lectora and all window related attributes
    getDisplayDocument()
    Returns the document object that is to be used for dealing with the visual HTML objects, it contains all of the currently HTML elements for the page
    GetCurrentPageDiv()
    Returns an HTML element that represents the page div
    GetCurrentPageID()
    Returns a string with the name of the current page div
    appendElement(obj, parentElement, htmlElement)
    This function can be used for attaching objects to the current page div; the customer would only need to pass in the last attribute as either a HTML element or a string.

    Please try using getDisplayWindow().addEventListener(“beforeunload”, blah); instead of window.add

    This post has received 1 vote up.
    #345616 Score: 0
    Profile photo of approg
    approg
    Member
    beginner
    intermediate
    curious george
    wise owl
    contributor
    friend finder
    picture perfect
    10 pts
    @approg

    Thanks that very good info to know.

    getDisplayWindow() and getDisplayDocument() appear to refer (in seamless) to the parent window so don’t trigger an onbeforeunload when the page changes.

    After some testing I think the issue is that I’m not listening for the correct event. If I do

    window.addEventListener(“unload”, blah);

    within the page then it does trigger when the page changes.

    One other question: does the function isSinglePagePlayerAvail return true if the title is being run as seamless?

    #345665 Score: 0
    Profile photo of Johnattan Barona
    Johnattan Barona
    Member
    beginner
    intermediate
    wise owl
    1 pt
    @jbarona9656

    Yes isSinglePagePlayerAvail() returns true only if the title had to ability to start in Seamless, for example in IE8 and IE9 this will return false as Seamless is not supported in these browsers.

Viewing 8 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic.