Closed Thread Icon

Topic awaiting preservation: How can I set embedded objects via script? Pages that link to <a href="https://ozoneasylum.com/backlink?for=8327" title="Pages that link to Topic awaiting preservation: How can I set embedded objects via script?" rel="nofollow" >Topic awaiting preservation: How can I set embedded objects via script?\

 
Author Thread
Pugzly
Paranoid (IV) Inmate

From: 127.0.0.1
Insane since: Apr 2000

posted posted 10-01-2002 20:51

I need to set the following, but only in a function:

code:
<!-- START MSN MESSENGER SCRIPTS //-->
<object classid="clsid:F3A614DC-ABE0-11d2-A441-00C04F795683" codebase="#Version=2,0,0,83" codetype="application/x-oleobject" id="MsgrObj" width="0" height="0"></object>
<object classid="clsid:FB7199AB-79BF-11d2-8D94-0000F875C541" codeType="application/x-oleobject" id="MsgrApp" width="0" height="0"></object>
<!-- END MSN MESSENGER SCRIPTS //-->



Emperor suggested I document.write it, but that causes the browser to wipe the window.

Suggestions?

Slime
Lunatic (VI) Mad Scientist

From: Massachusetts, USA
Insane since: Mar 2000

posted posted 10-01-2002 20:58

What do you mean "set" it? Insert it? You could use innerHTML, or document.createElement('object'); along with setAttribute to create the elements.

Pugzly
Paranoid (IV) Inmate

From: 127.0.0.1
Insane since: Apr 2000

posted posted 10-01-2002 21:05

The problem is that if I just insert the <object> stuff in the header, it launches MSN Messenger when a user comes to the page. I only want it to happen if they click a link, which, in turn, fires the function.

So....
document.createElement('object'); along with setAttribute would probably be the best way. I'm heading off to figure these two commands out.

Thanks for the info!

Pugzly
Paranoid (IV) Inmate

From: 127.0.0.1
Insane since: Apr 2000

posted posted 10-01-2002 21:51

Hmmm - I thought I understood what I read about this, but this isn't working - "null or not an object" error on the getElementById line
:

code:
<script type="text/javascript" language="javascript">
function tryme(msn_handle){
newObject = document.createElement("object");
newObject.setAttribute("clsid", "clsid:F3A614DC-ABE0-11d2-A441-00C04F795683");
newObject.setAttribute("codebase", "#Version=2,0,0,83");
newObject.setAttribute("codetype", "application/x-oleobject");
newObject.setAttribute("id", "MsgrObj");
newObject.setAttribute("width", "0");
newObject.setAttribute("height", "0");

newObject2 = document.createElement("object");
newObject2.setAttribute("clsid", "clsid:FB7199AB-79BF-11d2-8D94-0000F875C541");
newObject2.setAttribute("codetype", "application/x-oleobject");
newObject2.setAttribute("id", "MsgrApp");
newObject2.setAttribute("width", "0");
newObject2.setAttribute("height", "0");

document.getElementById('MsgrApp').LaunchAddContactUI(msn_handle);
}
</script>

<a href="javascript:tryme('pat@runningwolf.com');">add contact</a>




I should add that I've also tried adding

code:
document.body.appendChild(newObject);
document.body.appendChild(newObject2);



but that doesn't seem to help.


[This message has been edited by Pugzly (edited 10-01-2002).]

norm
Paranoid (IV) Inmate

From: [s]underwater[/s] under-snow in Juneau
Insane since: Sep 2002

posted posted 10-05-2002 03:03

This is a bit of a workaround, but I have used it succesfully in the past for object/embed . Create a hidden I-Frame loaded with a blank HTML page. Set your onclick to load a page with your object/embed into the I-Frame. Not a very elegant solution, but it works.



when I know everything, will my brain
stop hurting so much when I code?

Slime
Lunatic (VI) Mad Scientist

From: Massachusetts, USA
Insane since: Mar 2000

posted posted 10-05-2002 08:26

I believe this specific problem is caused by an IE bug: setting the ID of an element with setAttribute doesn't make IE recognize it's ID.

The workaround is to get the parent element (call it parelem or something) and execute the lines:

a=parelem.innerHTML;
if (a) parelem.innerHTML = a+'';

before you use getElementById.

psych3
Nervous Wreck (II) Inmate

From: Australia
Insane since: Feb 2001

posted posted 10-05-2002 22:31

you might try creating some varaibles and then using those variables in setAttribute() as i suspect all the : in your code are causing the error to be thrown; heres something I do with a dynamically generated iframe that demonstrats creating a variable and then stuffing it in setAttribute()

function makeIFrame() {
var iframe = document.createElement("iframe");
var ifSty = "position:absolute; width:1px; left:-200px; height:1px; visibility:hidden; id=frameData name=frameData scrolling=no ";
iframe.setAttribute("src", "");
iframe.setAttribute("id", "frameData");
iframe.setAttribute("name", "frameData")
iframe.style.cssText = ifSty;
iframe.setAttribute("style", ifSty);
document.body.appendChild(iframe);
}

Another option is to use innerhtml I use this to dynamically generate a flash movie at http://333creativecentral.com/ so in principle it should work for you.

function loadFlash(theurl,width,height) {
music.htm.innerHTML ='<object classid="clsid 27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="'+ width + '" height="'+ height + '"><param name="movie" value=" '+ theurl + '" /><param name="quality" value="high" /><param name="SCALE" value="exactfit" /><embed src="'+ theurl + '" width="'+ width + '" height="'+ height + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" scale="exactfit" /><\/embed><\/object>';
}

Hope this helps some

Eddie Traversa http://dhtmlnirvana.com/
http://333creativecentral.com/

[This message has been edited by psych3 (edited 10-05-2002).]

« BackwardsOnwards »

Show Forum Drop Down Menu