Skip to main content
Participant
August 10, 2010
Question

cpSetValue doesn't work in Firefox and Chrome?

  • August 10, 2010
  • 1 reply
  • 786 views

I've made changes in CaptivateMaintimeline.as as suggested by Jim Leichliter in his blog. And I use the following simple htm:

<!-- Copyright [2008] Adobe Systems Incorporated.  All rights reserved -->

<!-- saved from url=(0013)about:internet -->

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"

"http://www.w3.org/TR/html4/loose.dtd">

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

<title>test</title>

<script src="standard.js" type="text/javascript"></script>

</head>

<body   bgcolor="#F1F4F5">

<center>

<div id="CaptivateContent"> 

</div>

<script type="text/javascript">

   var so = new SWFObject("test1.swf", "Captivate", "924", "557", "9", "#CCCCCC");

so.addParam("quality", "high");

so.addParam("name", "Captivate");

so.addParam("id", "Captivate");

so.addParam("wmode", "window");

so.addParam("bgcolor","#F1F4F5");

so.addParam("menu", "false");

so.addVariable("variable1", "value1");

so.setAttribute("redirectUrl", "http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash");

so.write("CaptivateContent");

</script>

<script type="text/javascript">

//document.getElementById('Captivate').focus();

//document.Captivate.focus();

setCaptivateVariable("username", "Ahmet Cetin");

setCaptivateVariable("useremail", "ahmet@cetin.info");

setCaptivateVariable("userid", "58345");

document.getElementById('Captivate').focus();

document.Captivate.focus();

//document.reload;

//JBL:  Custom Function to set Captivate Vars via Javascript

function setCaptivateVariable(myVariable, myValue)

    {

//alert(myVariable + ": " + myValue);

//alert("");

document.getElementById('Captivate').jim_cpSetValue(myVariable, myValue);

    }

</script>

</center>

</body>

</html>

When I run this in IE8, it works almost! perfectly (when I show $$useremail$$ in label in CP4, it shows only ahmet@cetin.inf - one character missing, but anyway, it is not really important for now).
The funny thing is this code doesn't work in Firefox or Chrome. But when I enable any of the alert inside the setCaptivateVariable function, it works also almost! perfectly. Any idea?

This topic has been closed for replies.

1 reply

Legend
August 10, 2010

Hi Ahmet and welcome to the forums!

When you use a text caption to display variables in Cp, you also have  the option to choose how many characters get displayed.  The default is  15.  If you know your variable will be larger, set the value  accordingly.  Also, document.getElementById('Captivate') works only for  IE.  document.Captivate works for the rest.  Look at the default.htm publishing  template provided by your Captivate install to see how they detect the  browser.  You can do it their way, but I prefer using jQuery to do the  browser detection.  It's cleaner and easier to implement.