Skip to main content
Inspiring
January 5, 2016
Answered

Question : Can I identify if my project is running as SWF or HTML5 ?

  • January 5, 2016
  • 1 reply
  • 442 views

Hello,

I have created a project as both SWF and HTML5 to run on various Windows based desktop computers.

In the project I would like to identify if the project is running as SWF or HTML.

I have looked at the system variables and can see that there is cpInfoIsStandalone to indicate if the project is SWF or EXE.

But, I cannot see how I can identify if the project is SWF or HTML 5.

Any thoughts would be greatly appreciated.

Thank you

Peter

Cardiff (Raining and cold)

Wales

UK

    This topic has been closed for replies.
    Correct answer TLCMediaDesign

    if ( typeof window.Captivate === 'object' )

      {

       alert( 'isSwf' );//setSomeVar

      }

      else

      { 

       alert( 'isHTML' );//setSomeVar

      }

    1 reply

    Inspiring
    January 5, 2016

    I'm answering my own question, but would still appreciate any better way to do this.

    I noticed that the SWF is called from a file ending in xxxxx.htm and the HTML5 is called by the index.html file.

    So I used some javascript (shown below) to look for the current file name in use by the browser and put it in to myURL variable.

    I can then use the myURL variable to identify whether the project is SWF or HTML5.

    if ( window.cpAPIInterface )

    {

    // GET THE URL AND STRIP OUT FILENAME INTO myURL VARIABLE //

    window.cpAPIInterface.setVariableValue('myURL', document.location.href.substring(document.location.href.lastIndexOf('/')+1))

    }


    I tested this and it appears to work.

    Peter

    Cardiff (Still raining, cold and now its dark)

    Wales

    UK

    TLCMediaDesign
    TLCMediaDesignCorrect answer
    Inspiring
    January 5, 2016

    if ( typeof window.Captivate === 'object' )

      {

       alert( 'isSwf' );//setSomeVar

      }

      else

      { 

       alert( 'isHTML' );//setSomeVar

      }

    Inspiring
    January 6, 2016

    TLC,

    Thank you.

    Your answer is much more elegant than mine.

    Peter