PDA

View Full Version : setData method on an object


Fon
01-21-2008, 05:43 PM
I'm trying to create a menu outside of an object which can change its contents. Here's what I've got:


<script type="text/javascript">
function nouveauData()
{
document.getElementById('mediabox').setData("URL", new.html);
return false;
}
</script>

<div id="boite">
<object id="mediabox" type="text/html" data="thingie.html"></object>

<a id="precedent" href="index.html"></a>
<a id="suivant" href="" onclick="nouveauData()">uuok</a>
<a id="fermer" href="" onclick="document.getElementById('boite').style.display='none'; return false;"></a>

</div>


The java script funciont is supposed to change the "mediabox" data from "thingie.html" to "new.html", but nothing seems to be happenning. The method to close the window works fine however. I'm assuming I have a small syntax error. Any pointers?

Thanks.

shyam
01-21-2008, 06:07 PM
<script type="text/javascript">
function nouveauData()
{
document.getElementById('mediabox').setData("URL", new.html);
return false;
}
</script>
<object id="mediabox" type="text/html" data="thingie.html"></object>


document.getElementById('mediabox').setAttribute('data', 'new.html');

Fon
01-21-2008, 06:28 PM
I don't know why you got rid of the setData method. I looked it up online. Is it nonstandard? And setAttribute does nothing. I tried it before and now I've tried it again. No dice. Hmm... mysterious. Any other suggestions?

A1ien51
01-22-2008, 12:23 AM
Are you linking all of the mediabox js files and all of the other files that it requires?

Eric

Fon
01-22-2008, 12:31 PM
Am I linking the mediabox js files and all of the other files that it requires?

There are no external js files. The mediabox object contains html data files, but I'm not sure I understood you're question correctly. Basically I want to be able to switch html data files in mediabox based on what someone clicks outside of mediabox.

Thanks.

shyam
01-22-2008, 12:39 PM
I don't know why you got rid of the setData method. I looked it up online. Is it nonstandard? And setAttribute does nothing.

the data methods are for manipulating text content not element attributes...take a look here http://www.quirksmode.org/dom/w3c_core.html#data...if u notice there is no setData method so the only way it can be used is if there is some other js code that is adding this method to that particular object (like Alien51 suggested mediabox.js perhaps...)

A1ien51
01-22-2008, 03:09 PM
From the site here: http://iaian7.com/webcode/Mediabox

It says you need these external JavaScript files:


<head>
...
<link rel="stylesheet" href="/css/mediabox.css" type="text/css" media="screen" />
...
<script src="/js/mootools.v1.11.js" type="text/javascript"></script>
<script src="/js/swfobject.js" type="text/javascript"></script>
<script src="/js/mediabox.js" type="text/javascript"></script>
...
</head>


Are we talking about the same library?

Eric