Problem with JavaScript

Hey everyone,

I am using a button to run JavaScript passing data back to a Flash Operator Panel page to dial a phone number.

There are two JavaScript parts - one when the page loads to tell the browser to use FOP to make a call and the other sends the call

window.addEventListener(‘message’, function(e) { parent.postMessage(e.data,’’); } , false);
window.opener.postMessage(“supervisedtransfer=phonenumber”, "
");

the behaviour is not constant and works sometimes and does not work at other times. It seems that bubble is doing something to the JavaScript. We are opening the Console and sometimes we can see the JavaScrip being sent and sometimes nothing happens at all.

Is there some way of triggering JavaScript that is more clean. Is there some specific JavaScript plugin that I could test with?

Any feedback here would be appreciated

Many thanks
Frank

G’day mate,
Would it be an idea to make sure that the page has loaded completely before you add event listeners?

Thanks buddy, -I will give that a try!

Just to clarify, do you mean to add a delay to the wf or is there some other way to detect once the page has fully loaded before triggering the JavaScript?

What I have done is moved the JavaScript to the last action and added and pause as you can see from the screen shots

image

Many thanks
Frank

I have added this workflow action and will test in the morning


Thanks again
Frank

Yes, that was exactly what I had in mind. As it does work sometimes I believe it’s a timing issue.

Try setting a timeout in your JS box(es):
setTimeout(function(){ //your stuff here }, 1000);

Add a console.log to your event listeners to confirm that they get called.

Did you make this work?

Yes, I believe that it has made a difference so thank you for your recommendation
I will also look at adding the delay to the script as well

This topic was automatically closed after 70 days. New replies are no longer allowed.