Skip to main content
Participant
January 9, 2009
Question

Javascript not working

  • January 9, 2009
  • 7 replies
  • 1209 views
Hi All,

I'm trying to use a javascript acton on a button for the first time - but can't seem to get anything to work?

I've tried the basic :

window.close() and also javascript:window.close()

but just can't seem to get it to do anything.

Any ideas?

Thanks,

Sam
    This topic has been closed for replies.

    7 replies

    The GigAuthor
    Participant
    January 16, 2009
    Hi Anne,

    On my PC running XP it seems to work sometimes and then not others?!

    To test if you can get any javascript working:

    Close Captivate & restart it fresh, then create a new project with a single button (as you mentioned) and add the following script to it:

    window.close()

    Preview the project in a web browser (F12) and it should work.

    I found for some reason on larger more complex projects or where I've tried several scripts that don't work the whole project seems to stop running scripts. May be some bug?

    Captiv8r
    Legend
    January 16, 2009
    Hi all

    Some research needs to be done here using Google. Different browsers will behave differently when it comes to closing the window. It all depends on how the window was opened to begin with as well as the browser in use as to whether it will even attempt to close. the bottom line on this issue is that there is no one size fits all, this script works 100% of the time in all circumstances code to do the trick. Because of that, I usually just advise to forego any scripting. Just configure the project to close when it is finished playing. Then configure any exit button to simply visit the last slide. The net result is the same. Button is clicked, project closes if it can. Then again, I'm a simple simon.

    I'm seeing questions related to using JavaScript. Are you generally comfortable with JavaScripting? I don't intend for this to come off the wrong way, but I sense that with the issues being posted related to scripting and how to test and all, it would seem that at least some in this thread haven't quite reached that comfort level.

    I might suggest that before attempting to climb on the JavaScript motorcycle and jump over a school bus, you first learn how to effectively control the motorcycle. Once you are certain you know how to operate the device, advance to opening windows, displaying documents and other scripting.

    One little tip related to JavaScripting. The JavaScript alert function is the simplest test you may issue. Sort of the "Hello world" of the JavaScripting realm.

    The bottom line is that you need to understand how things work with JavaScript and HTML generically before attempting to toss Captivate into the mix.

    Cheers... Rick
    KCWebPlaza-5meuTi
    Inspiring
    January 15, 2009
    If you're interested, I've previously posted an example of using JavaScript to close the browser window an avoiding the security dialog. I'm sure a search would find it...
    Participating Frequently
    January 16, 2009
    Hi all,

    I apologize first for my english (I'm French!).

    I'm currently encountered the same issue as "The Gig".

    My goal is to launch a pop-up html window which will contain a Word document. (We have in my company a security issue with the "Open file" + "New" functionality). So I'm trying to find an other way to open a Word document in a new page from an elearning (created with Captivate).

    Because nothing happens with my initial script, I just put a simple javascript to a button in order to make it work.
    I tried all window.close, parent.close, window.parent.close... even with "javascript:" before the script. But NOTHING still happens !!!

    I am launching an HTML file which loads the SWF.
    And I am on XP.

    I just read that they could be some trouble with the standard.js file. If so, is it possible to someone to indicate me which changes to make on this file ?


    I hope someone could help me because I'm in a dead end!

    Thank you in advance,

    Anne
    Captiv8r
    Legend
    January 16, 2009
    Welcome to our community, Anne

    Can you please tell us where you read the bit about the standard.js file causing problems?

    Keep in mind that nowadays scripting (and testing scripting) is fraught with oh-so-many issues. Scripts sometimes won't work when you test locally but will work on a server. I believe most of it stems from browser security issues and the steps that the browser makers have had to take to thwart the writers of the nasty scripts.

    Cheers... Rick
    Participant
    January 14, 2009
    I've had a similar problem with the close button from the Captivate skin, running on WindowsXP. It works on Vista, however, it seems that the Standard.js Javascript is not being parsed on WindowsXP. With the presentation I am curently authoring, the preloader, and close button (both relying on Javascript) do not work on every machine. I have had multiple beta testers in the field report the same failures.
    Known Participant
    January 12, 2009
    Hi Sam,

    I just pop "parent.close();" into the Javascript and it works fine. I do still get the security warning because the window is being closed by something that didn't open it but my users (big multi-national) haven't even mentioned it.

    Hope it helps
    Inspiring
    January 12, 2009
    'Context' meaning, how are you launching the lesson? Is it in a frameset
    or is the Captivate file just in one HTML window?
    You are launching the HTML file, which loads in the Captive SWF, right?
    If you're just launching the SWF directly with no parent HTML window
    containing it, then the JS code has nothing to 'close'.
    Erik


    The Gig wrote:

    > Not sure about the context....

    --
    Erik Lord
    http://www.capemedia.net
    Adobe Community Expert - eLearning
    http://www.adobe.com/communities/experts/
    ------------------------------------------------------------------------
    http://www.awaretips.net - Authorware Tips!
    The GigAuthor
    Participant
    January 9, 2009
    Hi Erik,

    Not sure about the context....

    All I did was add a button to the inital slide on my captivate project and asigned some script to it - would you have some test script I could asign to a button to see if the javascript is actually 'firing'?

    Thanks,

    Sam
    Inspiring
    January 9, 2009
    What's the 'context'? Is the Captivate SWF loading inside a frameset?
    You can't close a frameset with window.close called from one of the
    frames - it would need to be something like parent.window.close
    Erik

    The Gig wrote:

    > window.close() and also javascript:window.close()
    >
    > but just can't seem to get it to do anything.

    --
    Erik Lord
    http://www.capemedia.net
    Adobe Community Expert - eLearning
    http://www.adobe.com/communities/experts/
    ------------------------------------------------------------------------
    http://www.awaretips.net - Authorware Tips!