Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

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

Engaged ,
Jan 05, 2016 Jan 05, 2016

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

369
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

People's Champ , Jan 05, 2016 Jan 05, 2016

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

  {

   alert( 'isSwf' );//setSomeVar

  }

  else

  { 

   alert( 'isHTML' );//setSomeVar

  }

Translate
Engaged ,
Jan 05, 2016 Jan 05, 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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Jan 05, 2016 Jan 05, 2016

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

  {

   alert( 'isSwf' );//setSomeVar

  }

  else

  { 

   alert( 'isHTML' );//setSomeVar

  }

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jan 06, 2016 Jan 06, 2016
LATEST

TLC,

Thank you.

Your answer is much more elegant than mine.

Peter

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Help resources