By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,384 Members | 1,886 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,384 IT Pros & Developers. It's quick & easy.

Safari Issue

P: n/a
I have a site that works perfectly in IE6 IE7 FF2 FF3 but not in the
latest Safari.

Here is the issue. I am attempting to call functions within a flash
object. When trying to attempt to retrieve the object to call the
functions IE6 IE7 FF2 FF3 all return Objects to work with. In Safari
a function is returned. Here is the code.

Expand|Select|Wrap|Line Numbers
  1. /
  2. *******************************************************************************
  3. **
  4. ** Advanced Distributed Learning Co-Laboratory (ADL Co-Lab) grants
  5. you
  6. ** ("Licensee") a non-exclusive, royalty free, license to use, modify
  7. and
  8. ** redistribute this software in source and binary code form, provided
  9. that
  10. ** i) this copyright notice and license appear on all copies of the
  11. software;
  12. ** and ii) Licensee does not utilize the software in a manner which
  13. is
  14. ** disparaging to ADL Co-Lab.
  15. **
  16. ** This software is provided "AS IS," without a warranty of any kind.
  17. ALL
  18. ** EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
  19. INCLUDING
  20. ** ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
  21. PURPOSE
  22. ** OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED.  ADL Co-Lab AND ITS
  23. LICENSORS
  24. ** SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A
  25. RESULT OF
  26. ** USING, MODIFYING OR DISTRIBUTING THE SOFTWARE OR ITS DERIVATIVES.
  27. IN NO
  28. ** EVENT WILL ADL Co-Lab OR ITS LICENSORS BE LIABLE FOR ANY LOST
  29. REVENUE,
  30. ** PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL,
  31. ** INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF
  32. THE
  33. ** THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE
  34. ** SOFTWARE, EVEN IF ADL Co-Lab HAS BEEN ADVISED OF THE POSSIBILITY OF
  35. SUCH
  36. ** DAMAGES.
  37. **
  38. *******************************************************************************/
  39.  
  40. /
  41. *******************************************************************************
  42. ** This file is part of the ADL Sample API Implementation intended to
  43. provide
  44. ** an elementary example of the concepts presented in the ADL Sharable
  45. ** Content Object Reference Model (SCORM).
  46. **
  47. ** The file is used by the run time environment to maintain internal
  48. communication
  49. ** within the frames of the environment.
  50. **
  51. *******************************************************************************/
  52.  
  53. var _Debug = true;  // set this to false to turn debugging off
  54. // and get rid of those annoying alert boxes.
  55.  
  56.  
  57. // local variable definitions
  58. var apiHandle = null;
  59. var API = null;
  60. var findAPITries = 0;
  61.  
  62.  
  63. /
  64. *******************************************************************************
  65. **
  66. ** Function: doInit()
  67. ** Inputs:  none
  68. ** Return:  false if the API handle cannot be located
  69. **
  70. ** Description: gets the API handle and sets up necessary api variable
  71. values
  72. **
  73. **
  74. *******************************************************************************/
  75. function initAPI()
  76. {
  77. var api = getAPIHandle();
  78. if (api == null)
  79. {
  80. alert("Unable to locate the RTE's API Implementation");
  81. return "false";
  82. }
  83. else
  84. {
  85. api.setActivityID( document.forms[0].activityID.value );
  86. api.setCourseID( document.forms[0].courseID.value );
  87. api.setStateID( document.forms[0].stateID.value );
  88. api.setUserID( document.forms[0].userID.value );
  89. api.setUserName( document.forms[0].userName.value );
  90. api.setNumAttempts( document.forms[0].numAttempts.value );
  91. api.clearState();
  92. }
  93. }
  94.  
  95.  
  96. /
  97. ******************************************************************************
  98. **
  99. ** Function getAPIHandle()
  100. ** Inputs:  None
  101. ** Return:  value contained by APIHandle
  102. **
  103. ** Description:
  104. ** Returns the handle to API object if it was previously set,
  105. ** otherwise it returns null
  106. **
  107. *******************************************************************************/
  108. function getAPIHandle()
  109. {
  110. if (apiHandle == null)
  111. {
  112. apiHandle = getAPI();
  113. }
  114. return apiHandle;
  115. }
  116.  
  117.  
  118. /
  119. *******************************************************************************
  120. **
  121. ** Function findAPI(win)
  122. ** Inputs:  win - a Window Object
  123. ** Return:  If an API object is found, it's returned, otherwise null
  124. is returned
  125. **
  126. ** Description:
  127. ** This function looks for an object named API in parent and opener
  128. windows
  129. **
  130. *******************************************************************************/
  131. function findAPI(win)
  132. {
  133.  
  134. while ((win.API_1484_11 == null) && (win.parent != null) &&
  135. (win.parent != win))
  136. {
  137. findAPITries++;
  138. // Note: 500 is a number based on the IEEE API Standards.
  139. if ( findAPITries 500 )
  140. {
  141. alert("Error finding API -- too deeply nested.");
  142. return null;
  143. }
  144.  
  145. win = win.parent;
  146.  
  147. }
  148. //ToDo:Start Here Debugging how to get Safari to see this object.
  149. return win.API_1484_11;
  150. }
  151.  
  152.  
  153.  
  154. /
  155. *******************************************************************************
  156. **
  157. ** Function getAPI()
  158. ** Inputs:  none
  159. ** Return:  If an API object is found, it's returned, otherwise null
  160. is returned
  161. **
  162. ** Description:
  163. ** This function looks for an object named API, first in the current
  164. window's
  165. ** frame hierarchy and then, if necessary, in the current window's
  166. opener window
  167. ** hierarchy (if there is an opener window).
  168. **
  169. *******************************************************************************/
  170. function getAPI()
  171. {
  172. var theAPI = findAPI(window);
  173. if ((theAPI == null) && (window.opener != null) &&
  174. (typeof(window.opener) != "undefined"))
  175. {
  176. theAPI = findAPI(window.opener);
  177. }
  178. if (theAPI == null)
  179. {
  180. alert("RTE - Can not locate API adapter");
  181. }
  182. return theAPI
  183. }
  184.  
  185.  
The code errors at
api.setActivityID( document.forms[0].activityID.value );

with
Value undefined(result of expression api.setActivityID) is not
object.

Low and behold it's not an object it's a function in the eyes of
safari.

Does anyone know a work around for this in safari.

Thank you,

Tim

Aug 8 '08 #1
Share this Question
Share on Google+
15 Replies


P: n/a
GinnTech wrote:
I have a site that works perfectly in IE6 IE7 FF2 FF3 but not in the
latest Safari.

Here is the issue. I am attempting to call functions within a flash
object. When trying to attempt to retrieve the object to call the
functions IE6 IE7 FF2 FF3 all return Objects to work with. In Safari
a function is returned. Here is the code.

[code]
This is Usenet. Do not bother (us) with pseudo-tags.
[...]
// local variable definitions
How can these be local variable definitions when they are in fact *global*
variable *declarations*?
var apiHandle = null;
var API = null;
This variable is never read.
var findAPITries = 0;

[...]
function initAPI()
{
var api = getAPIHandle();
A local variable named `api' is declared and initialized here.
if (api == null)
{
alert("Unable to locate the RTE's API Implementation");
return "false";
}
else
{
Since execution continues in this branch, getAPIHandle() would return a
value that is not equal to `null' after type conversion.
api.setActivityID( document.forms[0].activityID.value );
Since an error occurs when calling the method, getAPIHandle() would return a
value that is either not an object reference (but not equal to `null' after
type conversion) or the object referred to would not have such a method.
[...]
}
}

[...]
function getAPIHandle()
{
if (apiHandle == null)
{
apiHandle = getAPI();
}
return apiHandle;
}
[...]
function findAPI(win)
{

while ((win.API_1484_11 == null) && (win.parent != null) &&
(win.parent != win))
{
findAPITries++;
// Note: 500 is a number based on the IEEE API Standards.
if ( findAPITries 500 )
{
alert("Error finding API -- too deeply nested.");
return null;
}

win = win.parent;

}
//ToDo:Start Here Debugging how to get Safari to see this object.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^
return win.API_1484_11;
}
As everything boils down to this method, the problem that causes the error
in the first place is to be found in there. But ISTM debugging needs to be
started on top of it.
[...]
function getAPI()
{
var theAPI = findAPI(window);
if ((theAPI == null) && (window.opener != null) &&
(typeof(window.opener) != "undefined"))
{
theAPI = findAPI(window.opener);
}
if (theAPI == null)
{
alert("RTE - Can not locate API adapter");
}
return theAPI
}

[...]
The code errors at
api.setActivityID( document.forms[0].activityID.value );

with
Value undefined(result of expression api.setActivityID) is not
object.

Low and behold it's not an object it's a function in the eyes of
safari.
Utter nonsense. Safari very clearly says that the result of
api.setActivityID, which is the `undefined' value is not an
object (and so also no Function object).
Does anyone know a work around for this in safari.
if (api)

instead of

if (api == null)

might suffice to avoid the runtime error.

Nevertheless, the code would still have several other issues.
PointedEars
--
Prototype.js was written by people who don't know javascript for people
who don't know javascript. People who don't know javascript are not
the best source of advice on designing systems that use javascript.
-- Richard Cornford, cljs, <f8*******************@news.demon.co.uk>
Aug 9 '08 #2

P: n/a
GinnTech wrote:
I have a site that works perfectly in IE6 IE7 FF2 FF3 but not in the
latest Safari.

Here is the issue. I am attempting to call functions within a flash
object. When trying to attempt to retrieve the object to call the
functions IE6 IE7 FF2 FF3 all return Objects to work with. In Safari
a function is returned. Here is the code.

Expand|Select|Wrap|Line Numbers
  1. /
  2. *******************************************************************************
Expand|Select|Wrap|Line Numbers
  1.  
  2. Please wrap code for posting at about 70 characters to avoide errors
  3. being introduced by auto-wrapping.  Code should be able to be cut and
  4. pasted without any additional syntax errors.
  5.  
  6. [...]
  7.         
  8.                 /
  9. *******************************************************************************
  10. ** This file is part of the ADL Sample API Implementation intended to
  11. provide
  12. ** an elementary example of the concepts presented in the ADL Sharable
  13. ** Content Object Reference Model (SCORM).
  14. **
  15. ** The file is used by the run time environment to maintain internal
  16. communication
  17. ** within the frames of the environment.
  18. **
  19. *******************************************************************************/
  20. var _Debug = true;  // set this to false to turn debugging off
  21.                      // and get rid of those annoying alert boxes.
  22. // local variable definitions
  23.  
  24. They're global.
  25.  
  26.         
  27.                 var apiHandle = null;
  28. var API = null;
  29.  
  30. Unused variable
  31.  
  32.         
  33.                 var findAPITries = 0;
  34. /
  35. **
  36. **
  37. ** Function: doInit()
  38.  
  39. It's called doInit here...
  40.  
  41.         
  42.                 ** Inputs:  none
  43. ** Return:  false if the API handle cannot be located
  44. **
  45. ** Description: gets the API handle and sets up necessary api variable
  46. values
  47. **
  48. **
  49. *******************************************************************************/
  50.  
  51. and initAPI here
  52.  
  53.         
  54.                 function initAPI()
  55. {
  56.    var api = getAPIHandle();
  57.  
  58. getAPIHandle() returns the result of a call to getAPI(), which in turn
  59. calls findAPI(window).  For me, api is set to undefined.
  60.  
  61.  
  62.         
  63.                    if (api == null)
  64.  
  65. It isn't null, it's undefined but the test returns true anyway.  Consider:
  66.  
  67. if (typeof api != 'object');
  68.  
  69.         
  70.                    {
  71.       alert("Unable to locate the RTE's API Implementation");
  72.       return "false";
  73.  
  74. Do you really mean to return the string 'false' or the boolean value false?
  75.  
  76.  
  77.         
  78.                    }
  79.    else
  80.    {
  81.        api.setActivityID( document.forms[0].activityID.value );
  82.        api.setCourseID( document.forms[0].courseID.value );
  83.        api.setStateID( document.forms[0].stateID.value );
  84.        api.setUserID( document.forms[0].userID.value );
  85.        api.setUserName( document.forms[0].userName.value );
  86.        api.setNumAttempts( document.forms[0].numAttempts.value );
  87.        api.clearState();
  88.     }
  89. }
  90. /
  91. ******************************************************************************
  92. **
  93. ** Function getAPIHandle()
  94. ** Inputs:  None
  95. ** Return:  value contained by APIHandle
  96. **
  97. ** Description:
  98. ** Returns the handle to API object if it was previously set,
  99. ** otherwise it returns null
  100. **
  101. *******************************************************************************/
  102. function getAPIHandle()
  103. {
  104.    if (apiHandle == null)
  105.    {
  106.       apiHandle = getAPI();
  107.    }
  108.    return apiHandle;
  109. }
  110. /
  111. *******************************************************************************
  112. **
  113. ** Function findAPI(win)
  114. ** Inputs:  win - a Window Object
  115. ** Return:  If an API object is found, it's returned, otherwise null
  116. is returned
  117.  
  118. It seems it will return the result of win.API_1484_11, which is likely
  119. to be undefined, not null.
  120.  
  121.         
  122.                 **
  123. ** Description:
  124. ** This function looks for an object named API in parent and opener
  125. windows
  126. **
  127. *******************************************************************************/
  128. function findAPI(win)
  129. {
  130.    while ((win.API_1484_11 == null) && (win.parent != null) &&
  131. (win.parent != win))
  132.  
  133. A reference to the window object is passed to win, the first two tests
  134. are true but the last is false, so the while loop is never entered.
  135.  
  136.  
  137.         
  138.                    {
  139.       findAPITries++;
  140.       // Note: 500 is a number based on the IEEE API Standards.
  141.       if ( findAPITries 500 )
  142.       {
  143.          alert("Error finding API -- too deeply nested.");
  144.          return null;
  145.       }
  146.       win = win.parent;
  147.    }
  148.     //ToDo:Start Here Debugging how to get Safari to see this object.
  149.    return win.API_1484_11;
  150.  
  151. That returns undefined for me, not null as specified in the documentation.
  152.  
  153.         
  154.                 }
  155. /
  156. *******************************************************************************
  157. **
  158. ** Function getAPI()
  159. ** Inputs:  none
  160. ** Return:  If an API object is found, it's returned, otherwise null
  161. is returned
  162. **
  163. ** Description:
  164. ** This function looks for an object named API, first in the current
  165. window's
  166. ** frame hierarchy and then, if necessary, in the current window's
  167. opener window
  168. ** hierarchy (if there is an opener window).
  169. **
  170. *******************************************************************************/
  171. function getAPI()
  172. {
  173.    var theAPI = findAPI(window);
  174.    if ((theAPI == null) && (window.opener != null) &&
  175. (typeof(window.opener) != "undefined"))
  176.    {
  177.       theAPI = findAPI(window.opener);
  178.    }
  179.    if (theAPI == null)
  180.    {
  181.       alert("RTE - Can not locate API adapter");
  182.    }
  183.    return theAPI
  184. }
  185.  
  186.  
>
The code errors at
api.setActivityID( document.forms[0].activityID.value );
You don't show how you call the code, calling getAPI from window.onload
gives "RTE - Can not locate API adapter"

with
Value undefined(result of expression api.setActivityID) is not
object.

Low and behold it's not an object it's a function in the eyes of
safari.
The code you posted doesn't do that for me. Perhaps you should post a
link to a minimal example that shows the error.
--
Rob
Aug 10 '08 #3

P: n/a
On Aug 10, 1:19*am, RobG <rg...@iinet.net.auwrote:
GinnTech wrote:
I have a site that works perfectly in IE6 IE7 FF2 FF3 but not in the
latest Safari.
Here is the issue. *I am attempting to call functions within a flash
object. *When trying to attempt to retrieve the object to call the
functions IE6 IE7 FF2 FF3 all return Objects to work with. *In Safari
a function is returned. *Here is the code.
Expand|Select|Wrap|Line Numbers
  1.  /
  2.  *******************************************************************************
Expand|Select|Wrap|Line Numbers
  1. Please wrap code for posting at about 70 characters to avoide errors
  2. being introduced by auto-wrapping. *Code should be able to be cut and
  3. pasted without any additional syntax errors.
  4. [...]
  5.         
  6.                  /
  7.  *******************************************************************************
  8.  ** This file is part of the ADL Sample API Implementation intended to
  9.  provide
  10.  ** an elementary example of the concepts presented in the ADL Sharable
  11.  ** Content Object Reference Model (SCORM).
  12.  **
  13.  ** The file is used by the run time environment to maintain internal
  14.  communication
  15.  ** within the frames of the environment.
  16.  **
  17.  *******************************************************************************/
  •  
  •         
  •                  var _Debug = true; *// set this to false to turn debugging off
  •  * * * * * * * * * * *// and get rid of those annoying alert boxes.
  •  
  •         
  •                  // local variable definitions
  •  
  • They're global.
  •         
  •                  var apiHandle = null;
  •  var API = null;
  •  
  • Unused variable
  •         
  •                  var findAPITries = 0;
  •  
  •         
  •                  /
  •  **
  •  **
  •  ** Function: doInit()
  •  
  • It's called doInit here...
  •         
  •                  ** Inputs: *none
  •  ** Return: *false if the API handle cannot be located
  •  **
  •  ** Description: gets the API handle and sets up necessary api variable
  •  values
  •  **
  •  **
  •  *******************************************************************************/
  •  
  • and initAPI here
  •         
  •                  function initAPI()
  •  {
  •  * *var api = getAPIHandle();
  •  
  • getAPIHandle() returns the result of a call to getAPI(), which in turn
  • calls findAPI(window). *For me, api is set to undefined.
  •         
  •                  * *if (api == null)
  •  
  • It isn't null, it's undefined but the test returns true anyway. *Consider:
  • * * *if (typeof api != 'object');
  •         
  •                  * *{
  •  * * * alert("Unable to locate the RTE's API Implementation");
  •  * * * return "false";
  •  
  • Do you really mean to return the string 'false' or the boolean value false?
  •         
  •                  * *}
  •  * *else
  •  * *{
  •  * * * *api.setActivityID( document.forms[0].activityID.value );
  •  * * * *api.setCourseID( document.forms[0].courseID.value );
  •  * * * *api.setStateID( document.forms[0].stateID.value );
  •  * * * *api.setUserID( document.forms[0].userID.value );
  •  * * * *api.setUserName( document.forms[0].userName.value );
  •  * * * *api.setNumAttempts( document.forms[0].numAttempts.value );
  •  * * * *api.clearState();
  •  * * }
  •  }
  •  
  •         
  •                  /
  •  ******************************************************************************
  •  **
  •  ** Function getAPIHandle()
  •  ** Inputs: *None
  •  ** Return: *value contained by APIHandle
  •  **
  •  ** Description:
  •  ** Returns the handle to API object if it was previously set,
  •  ** otherwise it returns null
  •  **
  •  *******************************************************************************/
  •  function getAPIHandle()
  •  {
  •  * *if (apiHandle == null)
  •  * *{
  •  * * * apiHandle = getAPI();
  •  * *}
  •  * *return apiHandle;
  •  }
  •  
  •         
  •                  /
  •  *******************************************************************************
  •  **
  •  ** Function findAPI(win)
  •  ** Inputs: *win - a Window Object
  •  ** Return: *If an API object is found, it's returned, otherwise null
  •  is returned
  •  
  • It seems it will return the result of win.API_1484_11, which is likely
  • to be undefined, not null.
  •         
  •                  **
  •  ** Description:
  •  ** This function looks for an object named API in parent and opener
  •  windows
  •  **
  •  *******************************************************************************/
  •  function findAPI(win)
  •  {
  •  
  •         
  •                  * *while ((win.API_1484_11 == null) && (win.parent != null) &&
  •  (win.parent != win))
  •  
  • A reference to the window object is passed to win, the first two tests
  • are true but the last is false, so the while loop is never entered.
  •         
  •                  * *{
  •  * * * findAPITries++;
  •  * * * // Note: 500 is a number based on the IEEE API Standards.
  •  * * * if ( findAPITries 500 )
  •  * * * {
  •  * * * * *alert("Error finding API -- too deeply nested.");
  •  * * * * *return null;
  •  * * * }
  •  
  •         
  •                  * * * win = win.parent;
  •  
  •         
  •                  * *}
  •  * *//ToDo:Start Here Debugging how to get Safari to see this object..
  •  * *return win.API_1484_11;
  •  
  • That returns undefined for me, not null as specified in the documentation..
  •         
  •                  }
  •  
  •         
  •                  /
  •  *******************************************************************************
  •  **
  •  ** Function getAPI()
  •  ** Inputs: *none
  •  ** Return: *If an API object is found, it's returned, otherwise null
  •  is returned
  •  **
  •  ** Description:
  •  ** This function looks for an object named API, first in the current
  •  window's
  •  ** frame hierarchy and then, if necessary, in the current window's
  •  opener window
  •  ** hierarchy (if there is an opener window).
  •  **
  •  *******************************************************************************/
  •  function getAPI()
  •  {
  •  * *var theAPI = findAPI(window);
  •  * *if ((theAPI == null) && (window.opener != null) &&
  •  (typeof(window.opener) != "undefined"))
  •  * *{
  •  * * * theAPI = findAPI(window.opener);
  •  * *}
  •  * *if (theAPI == null)
  •  * *{
  •  * * * alert("RTE - Can not locate API adapter");
  •  * *}
  •  * *return theAPI
  •  }
  •  
  •         
  •  
  •  
  •  
  • The code errors at
    * * * *api.setActivityID( document.forms[0].activityID.value );

    You don't show how you call the code, calling getAPI from window.onload
    gives "RTE - Can not locate API adapter"
    with
    Value undefined(result of expression api.setActivityID) is not
    object.
    Low and behold it's not an object it's a function in the eyes of
    safari.

    The code you posted doesn't do that for me. *Perhaps you should post a
    link to a minimal example that shows the error.

    --
    Rob
    Ok I think that the point of the question is being missed here. The
    Code works fine. It's passed SCORM compliance and does exactly what
    it is supposed to do in every other browser except Safari. I did not
    write this code. I am only modifying it to work with Safari.

    Do to security issues I can not show or tell you how this code is
    used. I don't want to end up in Guantanamo Bay for violating
    government privacy rules.

    The API_1484_11 is a variable on the parent page that points to a
    Flash Object. When I get back to the office on MOnday I will include
    that code. I wouldn't get so caught up in the code so much as how in
    the world in Safari can I find this object and reference it as an
    object and not what is happening now it's being found but is being
    referenced as a function.

    Thank you for your help.

    Tim
    Aug 10 '08 #4

    P: n/a
    On Aug 10, 1:19*am, RobG <rg...@iinet.net.auwrote:
    GinnTech wrote:
    I have a site that works perfectly in IE6 IE7 FF2 FF3 but not in the
    latest Safari.
    Here is the issue. *I am attempting to call functions within a flash
    object. *When trying to attempt to retrieve the object to call the
    functions IE6 IE7 FF2 FF3 all return Objects to work with. *In Safari
    a function is returned. *Here is the code.
    Expand|Select|Wrap|Line Numbers
    1.  /
    2.  *******************************************************************************
    Expand|Select|Wrap|Line Numbers
    1. Please wrap code for posting at about 70 characters to avoide errors
    2. being introduced by auto-wrapping. *Code should be able to be cut and
    3. pasted without any additional syntax errors.
    4. [...]
    5.         
    6.                  /
    7.  *******************************************************************************
    8.  ** This file is part of the ADL Sample API Implementation intended to
    9.  provide
    10.  ** an elementary example of the concepts presented in the ADL Sharable
    11.  ** Content Object Reference Model (SCORM).
    12.  **
    13.  ** The file is used by the run time environment to maintain internal
    14.  communication
    15.  ** within the frames of the environment.
    16.  **
    17.  *******************************************************************************/
  •  
  •         
  •                  var _Debug = true; *// set this to false to turn debugging off
  •  * * * * * * * * * * *// and get rid of those annoying alert boxes.
  •  
  •         
  •                  // local variable definitions
  •  
  • They're global.
  •         
  •                  var apiHandle = null;
  •  var API = null;
  •  
  • Unused variable
  •         
  •                  var findAPITries = 0;
  •  
  •         
  •                  /
  •  **
  •  **
  •  ** Function: doInit()
  •  
  • It's called doInit here...
  •         
  •                  ** Inputs: *none
  •  ** Return: *false if the API handle cannot be located
  •  **
  •  ** Description: gets the API handle and sets up necessary api variable
  •  values
  •  **
  •  **
  •  *******************************************************************************/
  •  
  • and initAPI here
  •         
  •                  function initAPI()
  •  {
  •  * *var api = getAPIHandle();
  •  
  • getAPIHandle() returns the result of a call to getAPI(), which in turn
  • calls findAPI(window). *For me, api is set to undefined.
  •         
  •                  * *if (api == null)
  •  
  • It isn't null, it's undefined but the test returns true anyway. *Consider:
  • * * *if (typeof api != 'object');
  •         
  •                  * *{
  •  * * * alert("Unable to locate the RTE's API Implementation");
  •  * * * return "false";
  •  
  • Do you really mean to return the string 'false' or the boolean value false?
  •         
  •                  * *}
  •  * *else
  •  * *{
  •  * * * *api.setActivityID( document.forms[0].activityID.value );
  •  * * * *api.setCourseID( document.forms[0].courseID.value );
  •  * * * *api.setStateID( document.forms[0].stateID.value );
  •  * * * *api.setUserID( document.forms[0].userID.value );
  •  * * * *api.setUserName( document.forms[0].userName.value );
  •  * * * *api.setNumAttempts( document.forms[0].numAttempts.value );
  •  * * * *api.clearState();
  •  * * }
  •  }
  •  
  •         
  •                  /
  •  ******************************************************************************
  •  **
  •  ** Function getAPIHandle()
  •  ** Inputs: *None
  •  ** Return: *value contained by APIHandle
  •  **
  •  ** Description:
  •  ** Returns the handle to API object if it was previously set,
  •  ** otherwise it returns null
  •  **
  •  *******************************************************************************/
  •  function getAPIHandle()
  •  {
  •  * *if (apiHandle == null)
  •  * *{
  •  * * * apiHandle = getAPI();
  •  * *}
  •  * *return apiHandle;
  •  }
  •  
  •         
  •                  /
  •  *******************************************************************************
  •  **
  •  ** Function findAPI(win)
  •  ** Inputs: *win - a Window Object
  •  ** Return: *If an API object is found, it's returned, otherwise null
  •  is returned
  •  
  • It seems it will return the result of win.API_1484_11, which is likely
  • to be undefined, not null.
  •         
  •                  **
  •  ** Description:
  •  ** This function looks for an object named API in parent and opener
  •  windows
  •  **
  •  *******************************************************************************/
  •  function findAPI(win)
  •  {
  •  
  •         
  •                  * *while ((win.API_1484_11 == null) && (win.parent != null) &&
  •  (win.parent != win))
  •  
  • A reference to the window object is passed to win, the first two tests
  • are true but the last is false, so the while loop is never entered.
  •         
  •                  * *{
  •  * * * findAPITries++;
  •  * * * // Note: 500 is a number based on the IEEE API Standards.
  •  * * * if ( findAPITries 500 )
  •  * * * {
  •  * * * * *alert("Error finding API -- too deeply nested.");
  •  * * * * *return null;
  •  * * * }
  •  
  •         
  •                  * * * win = win.parent;
  •  
  •         
  •                  * *}
  •  * *//ToDo:Start Here Debugging how to get Safari to see this object..
  •  * *return win.API_1484_11;
  •  
  • That returns undefined for me, not null as specified in the documentation..
  •         
  •                  }
  •  
  •         
  •                  /
  •  *******************************************************************************
  •  **
  •  ** Function getAPI()
  •  ** Inputs: *none
  •  ** Return: *If an API object is found, it's returned, otherwise null
  •  is returned
  •  **
  •  ** Description:
  •  ** This function looks for an object named API, first in the current
  •  window's
  •  ** frame hierarchy and then, if necessary, in the current window's
  •  opener window
  •  ** hierarchy (if there is an opener window).
  •  **
  •  *******************************************************************************/
  •  function getAPI()
  •  {
  •  * *var theAPI = findAPI(window);
  •  * *if ((theAPI == null) && (window.opener != null) &&
  •  (typeof(window.opener) != "undefined"))
  •  * *{
  •  * * * theAPI = findAPI(window.opener);
  •  * *}
  •  * *if (theAPI == null)
  •  * *{
  •  * * * alert("RTE - Can not locate API adapter");
  •  * *}
  •  * *return theAPI
  •  }
  •  
  •         
  •  
  •  
  •  
  • The code errors at
    * * * *api.setActivityID( document.forms[0].activityID.value );

    You don't show how you call the code, calling getAPI from window.onload
    gives "RTE - Can not locate API adapter"
    with
    Value undefined(result of expression api.setActivityID) is not
    object.
    Low and behold it's not an object it's a function in the eyes of
    safari.

    The code you posted doesn't do that for me. *Perhaps you should post a
    link to a minimal example that shows the error.

    --
    Rob Oh and this is all iniciated by calling the initAPI() the child
    page.
    API_1484_11 is already instantiated on the parent page by the code I
    will post tomorrow morning. The functions that are being called
    api.set.... are inside the flash ojbect and are set for full access.

    Thanks Tim
    Aug 10 '08 #5

    P: n/a
    GinnTech wrote:
    Ok I think that the point of the question is being missed here. The Code
    works fine.
    Obviously it does not.
    It's passed SCORM compliance
    Which has nothing to do with it being incompatible code.
    and does exactly what it is supposed to do in every other browser except
    Safari.
    That is indicative of bad code, because the features used are of "DOM Level
    0" which all UAs whould support (even Safari). What is your "every other
    browser" anyway? (I suppose only IE and Fx.)
    I did not write this code.
    And so you are not willing to help us help you fix it?
    I am only modifying it to work with Safari.
    Good luck. You have been told what to do already.
    Do to security issues I can not show or tell you how this code is used. I
    don't want to end up in Guantanamo Bay for violating government privacy
    rules.
    Don't you play stupid, please.
    The API_1484_11 is a variable on the parent page that points to a Flash
    Object.
    But either the algorithm to retrieve it does not work properly in Safari or
    there is no such object in Safari. So you need to find out the cause of
    this if it should work in Safari.
    I wouldn't get so caught up in the code so much as how in the world in
    Safari can I find this object and reference it as an object and not what
    is happening
    You are not making sense.
    now it's being found but is being referenced as a function.
    How did you get that idea?
    PointedEars
    --
    Use any version of Microsoft Frontpage to create your site.
    (This won't prevent people from viewing your source, but no one
    will want to steal it.)
    -- from <http://www.vortex-webdesign.com/help/hidesource.htm>
    Aug 10 '08 #6

    P: n/a
    The API_1484_11 is a variable on the parent page that points to a Flash
    Object.
    But either the algorithm to retrieve it does not work properly in
    Safari or
    there is no such object in Safari. So you need to find out the cause
    of
    this if it should work in Safari.

    Now your on point this is the exact problem with safari. And yes I do
    need to find out what the cause of this with Safari that is why I
    posted this.
    now it's being found but is being referenced as a function.
    How did you get that idea?

    Insert typeof(api) in FF2, FF3, IE6, IE7, and Opera it returns as an
    object. In safari it returns as a function, that is how.

    Now if anyone can help with this issue and not just a need to take
    sarcastic shots on forums I would be greatly appreciative of the
    help. There has to be a work around for if the object returns as a
    function (if(typeof(api) = 'function'){...}) an alternative to get it
    as an object. It has to be an issue with locating it in the parent
    because it works correctly is your code is executed on the page the
    object is located, this 'feature' only occurs when you are trying to
    access the object from a parent window.

    Thank you,
    Tim
    Aug 10 '08 #7

    P: n/a
    On Aug 10, 7:27*pm, GinnTech <Tim.Dale.G...@gmail.comwrote:
    The API_1484_11 *is a variable on the parent page that points to a Flash
    Object.

    But either the algorithm to retrieve it does not work properly in
    Safari or
    there is no such object in Safari. *So you need to find out the cause
    of
    this if it should work in Safari.

    Now your on point this is the exact problem with safari. *And yes I do
    need to find out what the cause of this with Safari that is why I
    posted this.
    now it's being found but is being referenced as a function.

    How did you get that idea?

    Insert typeof(api) in FF2, FF3, IE6, IE7, and Opera it returns as an
    object. *In safari it returns as a function, that is how.
    You aren't making any sense. Functions are objects in JavaScript and
    the exception Safari threw did not indicate an object of any kind.

    Were you joking before or is this really an example of my tax dollars
    at work?
    Aug 11 '08 #8

    P: n/a
    On Aug 10, 8:19*pm, David Mark <dmark.cins...@gmail.comwrote:
    On Aug 10, 7:27*pm, GinnTech <Tim.Dale.G...@gmail.comwrote:
    The API_1484_11 *is a variable on the parent page that points to a Flash
    Object.
    But either the algorithm to retrieve it does not work properly in
    Safari or
    there is no such object in Safari. *So you need to find out the cause
    of
    this if it should work in Safari.
    Now your on point this is the exact problem with safari. *And yes I do
    need to find out what the cause of this with Safari that is why I
    posted this.
    now it's being found but is being referenced as a function.
    How did you get that idea?
    Insert typeof(api) in FF2, FF3, IE6, IE7, and Opera it returns as an
    object. *In safari it returns as a function, that is how.

    You aren't making any sense. *Functions are objects in JavaScript and
    the exception Safari threw did not indicate an object of any kind.

    Were you joking before or is this really an example of my tax dollars
    at work?
    As much as I hate to say it yes, anyway possibly I am not being clear
    with the results.

    object as in a class object

    var test = new foo();
    test.bar()

    I should be getting back test not bar();

    probably more confusing, maybe not.

    if you take a paragraph tag var test = document.getElementById('some
    paragraph') you will get back an object and you can call functions of
    that object and so on. if you ran typeof(test) you would return
    'object', in my issue with safari that is returning 'function' so you
    can't access test.style test.id and so on.

    Make sence?

    Aug 11 '08 #9

    P: n/a
    On Aug 11, 12:32*am, GinnTech <Tim.Dale.G...@gmail.comwrote:
    On Aug 10, 8:19*pm, David Mark <dmark.cins...@gmail.comwrote:
    On Aug 10, 7:27*pm, GinnTech <Tim.Dale.G...@gmail.comwrote:
    The API_1484_11 *is a variable on the parent page that points to a Flash
    Object.
    But either the algorithm to retrieve it does not work properly in
    Safari or
    there is no such object in Safari. *So you need to find out the cause
    of
    this if it should work in Safari.
    Now your on point this is the exact problem with safari. *And yes Ido
    need to find out what the cause of this with Safari that is why I
    posted this.
    now it's being found but is being referenced as a function.
    How did you get that idea?
    Insert typeof(api) in FF2, FF3, IE6, IE7, and Opera it returns as an
    object. *In safari it returns as a function, that is how.
    You aren't making any sense. *Functions are objects in JavaScript and
    the exception Safari threw did not indicate an object of any kind.
    Were you joking before or is this really an example of my tax dollars
    at work?

    As much as I hate to say it yes, anyway possibly I am not being clear
    with the results.
    Quite possibly, but that is not the issue at hand.
    >
    object as in a class object
    A what?
    >
    var test = new foo();
    test.bar()

    I should be getting back test not bar();

    probably more confusing, maybe not.
    You are clearly very confused.
    >
    if you take a paragraph tag var test = document.getElementById('some
    paragraph') *you will get back an object and you can call functions of
    Not with that ID you won't.
    that object and so on. *if you ran typeof(test) *you would return
    'object', in my issue with safari that is returning 'function' *so you
    There's really no telling what it would return (though "object" is
    quite common.)
    can't access test.style test.id and so on.
    Just because it returns "function?" Think again.
    >
    Make sence?
    I have understand that you don't understand what you are doing and
    therefore cannot analyze or articulate your problem very well. I
    certainly hope this isn't a critical project.
    Aug 11 '08 #10

    P: n/a
    GinnTech wrote:
    On Aug 10, 8:24 pm, RobG <rg...@iinet.net.auwrote:
    >On Aug 11, 9:27 am, GinnTech <Tim.Dale.G...@gmail.comwrote:

    Please trim quotes and do not remove attribution.
    Which part of that did you not get, Google Groups idiot?
    [snipped hundreds of irrelevant lines]
    Here is some more information on the issue I am seeing if this helps.
    Of course it will not as it has nothing to do with it, half-wit. Safari
    very clearly says that your *object* is not there, so it does not matter
    what `typeof' would yield for its method.
    And maybe for those unnamed who believe this to all be a farse.
    Nobody implied that, luser.

    (I usually do not reply like this, but maybe that's the kind of language you
    are going to understand ...)
    PointedEars
    --
    Anyone who slaps a 'this page is best viewed with Browser X' label on
    a Web page appears to be yearning for the bad old days, before the Web,
    when you had very little chance of reading a document written on another
    computer, another word processor, or another network. -- Tim Berners-Lee
    Aug 11 '08 #11

    P: n/a
    On Aug 11, 3:44 pm, GinnTech wrote:
    <snip>
    Here is some more information on the issue I am seeing if
    this helps. And maybe for those unnamed who believe this
    to all be a farse.

    Built-in functions are not objects
    <snip>

    Your issue is with host objects/methods not built-in functions.
    Built-in functions in Safari are not Function objects, and
    not even Object objects. They appear to be of type "function"
    instead of type "object". This makes it impossible to use
    .call() and .apply() on them.

    (ppknote: Safari 3 gives window.alert instanceof Object:
    true. 1.3 doesn't, though.)

    Test page Workaround is not included
    This "test page" applies its tests to - window.alert -, which is not a
    built-in function, it is a host method/function. And being a host
    method/function there is no reason to expect it to have any particular
    object on its prototype chain, to inherit any methods through its
    prototype chain or to have any particular - prototype - property (or
    have such a property at all). Without any specified requirements upon
    - window.alert - it is not possible for any behaviour it may exhibit
    to be regarded as a bug; thus the bug report is bogus.
    Aug 11 '08 #12

    P: n/a
    On Aug 11, 11:20*am, Henry <rcornf...@raindrop.co.ukwrote:
    On Aug 11, 3:44 pm, GinnTech wrote:
    <snip>Here is some more information on the issue I am seeing if
    this helps. And maybe for those unnamed who believe this
    to all be a farse.
    Built-in functions are not objects

    <snip>

    Your issue is with host objects/methods not built-in functions.
    Built-in functions in Safari are not Function objects, and
    not even Object objects. They appear to be of type "function"
    instead of type "object". This makes it impossible to use
    .call() and .apply() on them.
    (ppknote: Safari 3 gives window.alert instanceof Object:
    true. 1.3 doesn't, though.)
    Test page Workaround is not included

    This "test page" applies its tests to - window.alert -, which is not a
    built-in function, it is a host method/function. And being a host
    method/function there is no reason to expect it to have any particular
    object on its prototype chain, to inherit any methods through its
    prototype chain or to have any particular - prototype - property (or
    have such a property at all). Without any specified requirements upon
    - window.alert - it is not possible for any behaviour it may exhibit
    to be regarded as a bug; thus the bug report is bogus.
    Ok I can accept that. But I still have the issue. With debugging
    today I was able to make a change implimenting the prototype framework
    and get the API_1484_11 Object to return as an 'object' and not a
    function using $('API_1484_11').

    After fixing this issue the issue reared it's head on another object
    being accessed on the page called 'TaskShell'. I tried the same $()
    function on it hopefully fixing it here as well. To no avail at this
    point in the code it still returns as a 'function'.

    Here is the code

    function getID(swfID) {
    if (navigator.appName.indexOf("Microsoft") -1) {
    alert("Thinks it's Microsoft");
    flash = window[swfID];
    } else {
    alert("Thinks it's Something else - safari/ff/Opera/other");
    flash = document[swfID];
    //alert(document[swfID].length);
    //flash = document.getElementsByName(swfID)[0];
    if(document[swfID].length != undefined){//ff/Opera
    alert("Thinks it's defined");
    flash = document[swfID][1];
    return;
    }else{//Safari
    alert("Thinks it's undefined");
    flash = document.getElementsByName('TaskShell')[0];
    // flash = $(swfID);
    alert(typeof(flash));
    return;
    }
    // flash = document[swfID];
    // return;
    }
    }
    //initialize the flash shell on this page (called from initLMS())
    function initFlashShell(){
    //get reference to flash shell
    getID('TaskShell');

    //initialize LMS API object
    initLMS();

    //initShell is in TaskShell.swf
    //send launch data for progress bar
    try{
    $('TaskShell').initShell(API_1484_11.GetValue("cmi .launch_data")
    +"&"+"<%=data %>");//Attempt to try and access it with prototype}
    catch(e){
    alert(e.toString());
    }
    //flash.initShell(API_1484_11.GetValue("cmi.launch_d ata")+"&"+"<
    %=data %>");
    }

    element it is trying to get
    <script type="text/javascript">
    AC_FL_RunContent( 'codebase','https://fpdownload.macromedia.com/pub/
    shockwave/cabs/flash/
    swflash.cab#version=8,0,0,0','id','TaskShell','wid th','815','height','750','align','middle','src','<
    %= mediaServerRoot %>flash/
    TaskShell','quality','high','bgcolor','#ffffff','s wliveconnect','true','name','TaskShell','allowscri ptaccess','always','pluginspage','https://
    www.macromedia.com/go/getflashplayer','movie','<%= mediaServerRoot
    %>flash/TaskShell' ); //end AC code
    </script><noscript><object classid="clsid:d27cdb6e-
    ae6d-11cf-96b8-444553540000" codebase="https://
    fpdownload.macromedia.com/pub/shockwave/cabs/flash/
    swflash.cab#version=8,0,0,0" id="TaskShell" width="815" height="750"
    align="middle">
    <param name="allowScriptAccess" value="always" />
    <param name="movie" value="<%= mediaServerRoot %>flash/
    TaskShell.swf" />
    <param name="quality" value="high" />
    <param name="bgcolor" value="#ffffff" />
    <embed src="<%= mediaServerRoot %>flash/TaskShell.swf"
    quality="high" bgcolor="#eae8e3" width="815" height="750"
    swLiveConnect=true id="TaskShell" name="TaskShell" align="middle"
    allowScriptAccess="always" type="application/x-shockwave-flash"
    pluginspage="https://www.macromedia.com/go/getflashplayer" />
    </object></noscript>
    Error thrown
    Value undefined (result of expression flash.initShell) is not object.
    localhost:8080/task_page.jsp?sourceurl=modules/amodule/Task01_module/
    module_01content.xml&suspended=false&moduleNum=10 (line 74)

    Thanks for the help

    Tim
    Aug 11 '08 #13

    P: n/a
    On Aug 12, 12:44*am, GinnTech <Tim.Dale.G...@gmail.comwrote:
    [...]
    Here is some more information on the issue I am seeing if this helps.
    I don't think it has anything to do with the issue.

    And maybe for those unnamed who believe this to all be a farse.

    Built-in functions are not objects
    Better to make quotes look like quotes, it appears as if you wrote
    that.
    >
    Permalink | Safari | 1 comments
    Reported on 17 August 2007

    Built-in functions in Safari are not Function objects, and not even
    Object objects. They appear to be of type "function" instead of type
    "object". This makes it impossible to use .call() and .apply() on
    them.

    (ppknote: Safari 3 gives window.alert instanceof Object: true. 1.3
    doesn't, though.)

    Test page Workaround is not included
    Reported by: Mihail Milushev.

    This can be found athttp://www.quirksmode.org/bugreports/archives/safari/index.html
    The poster of that is confused: in regard to javascript, the term
    "built-in" refers to features that are specified in ECMA-262. As far
    as I'm aware, all built-in functions in Safari conform to the
    specification, e.g.

    alert(typeof [].push); // function
    What the poster is actually testing is window.alert, which is a host
    object. Therefore all bets are off, they are not required by ECMA-262
    to have the same behaviour as built-in and native objects and
    functions.

    The confusion may stem from the fact that both Firefox and Safari (3
    at least) make most of their host objects very similar to native
    objects, e.g.

    alert( typeof document.getElementById );

    shows function in Firefox and Safari, but object in IE.
    alert( typeof document.getElementById.apply );

    shows function in Firefox and Safari, but undefined in IE. I don't
    see how this is related to the OP.
    --
    Rob
    Aug 12 '08 #14

    P: n/a
    Here is the fix and the issue.

    While I was trying to debug this issue I was using the apple provided
    "Execute a Script". Essentially just trying to throw things at this
    to get results I was wanting. The Prototype framework was the fix.
    This 'function' issue was rearing it's head because of how safari
    renders the page (for supposedly performance). In safari the actual
    page load event is not truly done once the page is fully loaded. I
    will say at least in this case concerning Flash. The .jsp page in
    this case yes may be loaded, but the swf had not been completely
    loaded when the script was being executed. So when the script tried
    to access the swf's exposed functions they were not available
    immediately. resulting in the return of a 'function' and not an
    'object'. I discovered this by executing

    $('TaskShell').initShell(API_1484_11.GetValue("cmi .launch_data")
    +"&"+"<%=data %>");

    after the page had been loaded a couple seconds and to all amazement
    the content loaded in the swf. The fix if you want to call it that is
    to check the flash object to see if it is being returned with a type
    of 'function'. If so I am pausing the execution of the script by 3
    seconds to allow for the swf to completely download and be available
    to the browser. Now all is good.

    Well I hope we all learned something and maybe this can help someone
    in the future. I know I now know more than I ever wanted to know about
    a browser less than 2% of the world uses.

    Thanks for all the help.

    Tim
    Aug 12 '08 #15

    P: n/a
    On Aug 13, 3:01*am, GinnTech <Tim.Dale.G...@gmail.comwrote:
    Here is the fix and the issue.

    While I was trying to debug this issue I was using the apple provided
    "Execute a Script". *Essentially just trying to throw things at this
    to get results I was wanting. *The Prototype framework was the fix.
    What part of Prototype.js is "the fix"?

    This 'function' issue was rearing it's head because of how safari
    renders the page (for supposedly performance). *In safari the actual
    page load event is not truly done once the page is fully loaded.
    There is no *guarantee* that all content has been loaded when the load
    event fires in any browser. Not loading a dependent resource will not
    stop the load event from occurring provided the resource that loads it
    is available.

    *I
    will say at least in this case concerning Flash. *The .jsp page in
    this case yes may be loaded, but the swf had not been completely
    loaded when the script was being executed. *So when the script tried
    to access the swf's exposed functions they were not available
    immediately. *resulting in the return of a 'function' and not an
    'object'. *I discovered this by executing

    $('TaskShell').initShell(API_1484_11.GetValue("cmi .launch_data")
    +"&"+"<%=data %>");

    after the page had been loaded a couple seconds and to all amazement
    the content loaded in the swf. *The fix if you want to call it that is
    to check the flash object to see if it is being returned with a type
    of 'function'. *If so I am pausing the execution of the script by 3
    seconds to allow for the swf to completely download and be available
    to the browser. *Now all is good.
    That strategy is called polling, it is not considered a good strategy
    but if it's the only solution then use it. You might want to poll a
    bit more frequently than every 3 seconds - say 200ms or so, depending
    on what else is happening in the page. You should also cancel polling
    after a reasonable number of attempts, the Flash object may not ever
    load.

    Well I hope we all learned something and maybe this can help someone
    in the future. I know I now know more than I ever wanted to know about
    a browser less than 2% of the world uses.
    It isn't necessarily about a particular browser, but allowing for a
    behaviour that is known to occur.
    --
    Rob
    Aug 13 '08 #16

    This discussion thread is closed

    Replies have been disabled for this discussion.