Jack
Jack

Reputation: 863

Calling javascript function from Coldfusion

Tried to call a javascript popup window using ColdFusion. Have not been able to do it.

The ColdFusion code is straight forward

<cfif notpaid>
    <script type="text/javascript">
    notpaid();
    </script>
</cfif>

It will pop up a window if a person is "notpaid". I tried it with alert() and it popup the alert box so the problem is not with this ColdFusion code.

One of the associated embedded javascripts is written as:

modalWin = new CreateModalPopUpObject();
modalWin.SetLoadingImagePath("/dev/images/loading.gif");
modalWin.SetCloseButtonImagePath("/dev/images/remove.gif");

function notpaid() {
    modalWin.Draggable=false;
    modalWin.ShowURL('https://www.sample.com/sample.htm', 320, 350, "Heading");
}
function HideModalWindow() {
    modalWin.HideModalPopUp();
    window.document.forms[1].submit();
}

The modalWin.ShowURL is the function that display the popup window and is proven working when it is associated with clicking, i.e. user click on a button and it will pop up the window.

In the new scenario, I am using ColdFusion to call without user interaction, but it won't pop up the window. I believe the problem lies with the javascript function notpaid(). I have tried different ways to no avail. I seen people talking about CF being server-side and javascript being client-side, but I do not know how to make the connection. I know with some proper code, it can be done. What am I missing here? Thanks in advance.

Upvotes: 2

Views: 2872

Answers (1)

Jack
Jack

Reputation: 863

I have finally figured it out. By changing the "function notpaid()" to:

notpaid = function() {
    modalWin.Draggable=false;
    modalWin.ShowURL("https://www.sample.com/sample.htm", 320, 350, "Heading");
}   

and the pop up worked. Don't know why, but it did the trick.

Upvotes: 2

Related Questions