I’m trying to embed a simple Quartz Composition into a webpage using the embed tag. According to Apple’s documentation and the API reference, this should be a very simple task, but selecting the embedded object in JavaScript doesn’t expose the API.
Here’s my page:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Quartz Test</title>
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>
<script type="text/javascript" src="script.js"></script>
</head>
<body>
<div id="main">
<h1>Quartz Test</h1>
<hr/>
<div id="content">
<embed type="application/x-quartzcomposer"
src="lineTest.qtz"
id="myComp"
width="300px"
height="150px"
opaque="false"/>
</div>
</div>
</body>
</html>
and here’s my js:
var composition;
$(document).ready(function() {
composition = $('#myComposiiton');
});
With this simple setup I should be able to write something like…
composition.loaded() //should be true
or
composition.inputKeys() //should return Array
Instead all I get are errors in the debugger like, TypeError: Result of expression ‘composition.loaded’ [undefined] is not a function.
Has anybody been through this or have suggestion on how I might be able to debug it?
Thanks
Have you tried the obvious composition[0].loaded() ?
The jQuery $ function returns an array of DOM elements that match your selection, even if there is only one element that matches.