Melisa Bok
2016-04-16 14:14:40 UTC
Hi!
I'm wanting to generate some tools to create DOM objects in the host place
and return the object created to the guest. I tried with several options
and I couldn't. Here is my code:
host.html
<html>
<head>
<title>Caja host page</title>
<script type="text/javascript" src="//caja.appspot.com/caja.js"/>
</script>
</head>
<body>
<h1>Caja host page</h1>
<div id="guest"></div>
<script type="text/javascript">
var createPanelReturnDom = function() {
var div = document.createElement("div");
var t = document.createTextNode("This is a paragraph");
div.appendChild(t);
return caja.tame(div);
}
var createPanelReceiveDom = function(dom) {
var div = document.createElement("div");
var t = document.createTextNode("This is a paragraph");
div.appendChild(t);
dom.appendChild(div);
}
caja.initialize({
cajaServer: 'https://caja.appspot.com',
forceES5Mode: true,
debug: true
});
caja.load(document.getElementById('guest'), caja.policy.net.ALL,
function(frame) {
frame.code('guest.html',
'text/html')
.api({ 'createPanelReturnDom':
caja.tame(caja.markFunction(createPanelReturnDom)),
'createPanelReceiveDom':
caja.tame(caja.markFunction(createPanelReceiveDom))
})
.run();
});
</script>
</body>
</html>
and guest.html
<html>
<head>
</head>
<body>
<div id='main'>Hello World!</div>
<script type="text/javascript">
// Test 1
// var main = document.getElementById('main');
// var panel = createPanelReturnDom();
// main.appendChild(panel);
// Test 2
createPanelReceiveDom(document.getElementById('main'));
</script>
</body>
</html>
When I run test 1 in the guest code I get: "This operation requires a
TameBackedNode in source"
and when I run test 2: "Untaming of guest constructed objects unsupported:
[domado object HTMLDivElement DIV]"
Even test 2 is explained in the API Reference
<http://google-caja.googlecode.com/svn/doc/cajajs/index.html> where it says
that you need to "unwrapDom" before using it in the host code. But I read
that is not longer necessary.
How can I pass DOM objects from one side to the other side?
Thank you so much for you help.
Melisa
I'm wanting to generate some tools to create DOM objects in the host place
and return the object created to the guest. I tried with several options
and I couldn't. Here is my code:
host.html
<html>
<head>
<title>Caja host page</title>
<script type="text/javascript" src="//caja.appspot.com/caja.js"/>
</script>
</head>
<body>
<h1>Caja host page</h1>
<div id="guest"></div>
<script type="text/javascript">
var createPanelReturnDom = function() {
var div = document.createElement("div");
var t = document.createTextNode("This is a paragraph");
div.appendChild(t);
return caja.tame(div);
}
var createPanelReceiveDom = function(dom) {
var div = document.createElement("div");
var t = document.createTextNode("This is a paragraph");
div.appendChild(t);
dom.appendChild(div);
}
caja.initialize({
cajaServer: 'https://caja.appspot.com',
forceES5Mode: true,
debug: true
});
caja.load(document.getElementById('guest'), caja.policy.net.ALL,
function(frame) {
frame.code('guest.html',
'text/html')
.api({ 'createPanelReturnDom':
caja.tame(caja.markFunction(createPanelReturnDom)),
'createPanelReceiveDom':
caja.tame(caja.markFunction(createPanelReceiveDom))
})
.run();
});
</script>
</body>
</html>
and guest.html
<html>
<head>
</head>
<body>
<div id='main'>Hello World!</div>
<script type="text/javascript">
// Test 1
// var main = document.getElementById('main');
// var panel = createPanelReturnDom();
// main.appendChild(panel);
// Test 2
createPanelReceiveDom(document.getElementById('main'));
</script>
</body>
</html>
When I run test 1 in the guest code I get: "This operation requires a
TameBackedNode in source"
and when I run test 2: "Untaming of guest constructed objects unsupported:
[domado object HTMLDivElement DIV]"
Even test 2 is explained in the API Reference
<http://google-caja.googlecode.com/svn/doc/cajajs/index.html> where it says
that you need to "unwrapDom" before using it in the host code. But I read
that is not longer necessary.
How can I pass DOM objects from one side to the other side?
Thank you so much for you help.
Melisa
--
---
You received this message because you are subscribed to the Google Groups "Google Caja Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-caja-discuss+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
---
You received this message because you are subscribed to the Google Groups "Google Caja Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-caja-discuss+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.