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

Captivate 8: JavaScript popup window

New Here ,
Nov 22, 2015 Nov 22, 2015

Hello!

I use the Execute JavaScript function in Captivate 8 and it works very well.  I want to modify this, though, for a project so that the popup opens in the center of the page.  Does anyone have experience with this or have any suggestions?  Here is the code I use in the script_window:

var win = window.open('url', 'popup', 'width=800, height=800, location=no, menubar=no, status=no, toolbar=no, scrollbars=no, resizable=no');

win.focus();


Thank you all in advance!

979
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
Community Beginner ,
Nov 22, 2015 Nov 22, 2015

A suggestion; is using Web Object an option in your project?

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
New Here ,
Nov 22, 2015 Nov 22, 2015

Thank you! That is a great idea, however, I want the object to open up in the center and the web object opens in the top left.  Is there a way to add that function into the web object? 

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
Community Beginner ,
Nov 22, 2015 Nov 22, 2015

In regards of web object on the top left, you can simply position your web object on the top left but hidden.

Next, you could create an Advanced Action.

First line, execute the script to show pop up

Send line, tell Captivate to show the hidden web object.

Next step, attach the Advanced action to a button. Now, when this button is pressed, a popup will appear and a web object will be visible on the top left.

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
Community Expert ,
Nov 22, 2015 Nov 22, 2015

Someone's not getting the memo or reading the replies. 

The original poster wants a SEPARATE popup window to open in the MIDDLE of the computer monitor.

Unfortunately, although getting a separate browser window to open IS possible, dictating where on the screen it opens is not something I have seen done.  And in HTML5 or responsive output it would be out of the question anyway.

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 ,
Nov 23, 2015 Nov 23, 2015

    var dualScreenLeft = window.screenLeft != undefined ? window.screenLeft : screen.left;
    var dualScreenTop = window.screenTop != undefined ? window.screenTop : screen.top;

    width = window.innerWidth ? window.innerWidth : document.documentElement.clientWidth ? document.documentElement.clientWidth : screen.width;
    height = window.innerHeight ? window.innerHeight : document.documentElement.clientHeight ? document.documentElement.clientHeight : screen.height;

    var left = ((width / 2) - (w / 2)) + dualScreenLeft;
    var top = ((height / 2) - (h / 2)) + dualScreenTop;
    var newWindow = window.open(url, title, 'scrollbars=yes, width=' + w + ', height=' + h + ', top=' + top + ', left=' + left);

   
    if (window.focus) {
        newWindow.focus();
    }

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
Community Expert ,
Nov 23, 2015 Nov 23, 2015
LATEST

Ahh.  I forgot we have a JavaScript guru in the house!

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