Forum Moderators: open

Message Too Old, No Replies

Open new window with movie clip

         

MadamC

8:37 pm on Dec 8, 2004 (gmt 0)

10+ Year Member



I'm a bigtime newbie and major step-by-step help!
Trying to open up a new javascript window with a movie clip (given below) once the user clicks on the link. The only thing that will be changing are the "MediaItem" values (the different movie clips) and the values will be given in a field. How can I insert the field value in here? Also, open up a new window showing the clip? Sorry, I don't know if I was able to explain that correctly...

<OBJECT ID="SeeVideo_Porsche" width=320 height=280 CLASSID="CLSID:68253470-5d4f-4cdf-8d9c-353c14a2f013" codebase="http://www.example.com/file.cab#version=2,5,13,110">
<PARAM NAME="ServerIP" VALUE="999.999.999.999">
<PARAM NAME="PortNum" VALUE="5000">
<PARAM NAME="MediaItem" VALUE="77872023">
<PARAM NAME="NoTicket" VALUE="1">
<PARAM NAME="AutoPlay" VALUE="1">
<PARAM NAME="RandomEnable" VALUE="1">
<PARAM NAME="SkinName" VALUE="2003default_320">
<PARAM NAME="SkinCodeBase" VALUE="http://www.example.com/otherfile.sbd#Version=31015">
</OBJECT>

Liz

whoisgregg

12:03 am on Dec 9, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Put this first block in between the <head></head> tags of your page:
<script type="text/javascript"> 
function popWithThis(MediaItem){
imgWin = window.open('','',id);
with (imgWin.document){
writeln('<html><head></head><body bgcolor=000000 scroll="no">');
writeln('<OBJECT ID="SeeVideo_Porsche" width=320 height=280 ');
writeln('CLASSID="CLSID:68253470-5d4f-4cdf-8d9c-353c14a2f013" ');
writeln('codebase="http://www.example.com/file.cab#version=2,5,13,110"> ');
writeln('<PARAM NAME="ServerIP" VALUE="999.999.999.999"> ');
writeln('<PARAM NAME="PortNum" VALUE="5000"> ');
writeln('<PARAM NAME="MediaItem" VALUE="'+MediaItem+'">');
writeln('<PARAM NAME="NoTicket" VALUE="1"> ');
writeln('<PARAM NAME="AutoPlay" VALUE="1"> ');
writeln('<PARAM NAME="RandomEnable" VALUE="1"> ');
writeln('<PARAM NAME="SkinName" VALUE="2003default_320"> ');
writeln('<PARAM NAME="SkinCodeBase"');
writeln('VALUE="http://www.example.com/otherfile.sbd#Version=31015"> ');
writeln('</OBJECT></body></html>');
}}
</script>

Then put this link somewhere on the page:
<a href="#" onclick="popWithThis('77872023');return false;">Test</a>

Let me know how that works out -- it's tested but it was also very very quickly thrown together. For the different links, you just swap out the number in the link. :)

MadamC

7:59 pm on Dec 10, 2004 (gmt 0)

10+ Year Member



Hmmm, when I test out the link and click on it, it goes to the page the link is on (just refreshes the page basically). Is the <a href="#"> correct?

whoisgregg

2:29 am on Dec 11, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Sorry for the bad code. The href="#" is fine, it's the javascript I threw together that's all boogered up. :)

It works in one browser only -- the one I tested in. All the rest choke because there are all sorts of characters which need to be escaped. Basically everywhere you see a "/" it needs to have a "\" in front of it, making "\/". I may have made other syntax errors as well, I have about ten minutes to get it working before I have to go...

If I don't post again tonight, I'll do my best to do it this weekend sometime. Perhaps someone more knowledgable will post an even better way of doing the whole thing. (This method is what I would describe as "brute force." There's probably a very smooth and simple way of accomplishing the same end goal.)

whoisgregg

2:37 am on Dec 11, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Easier than I thought, escaped the characters and named the new window and it should now work everywhere. Use this script code and the same link from above. If you need help figuring out how to set the size/scrollbars/etc. of the new window, just do a site search here for 'javascript window.open' and there's a lot of examples. :D

<script type="text/javascript">
function popWithThis(MediaItem){
imgWin = window.open('','Movie','');
with (imgWin.document){
writeln('<html><head><\/head><body bgcolor=000000 scroll="no">');
writeln('<OBJECT ID="SeeVideo_Porsche" width=320 height=280 ');
writeln('CLASSID="CLSID:68253470-5d4f-4cdf-8d9c-353c14a2f013" ');
writeln('codebase="http:\/\/www.example.com\/file.cab#version=2,5,13,110"> ');
writeln('<PARAM NAME="ServerIP" VALUE="999.999.999.999"> ');
writeln('<PARAM NAME="PortNum" VALUE="5000"> ');
writeln('<PARAM NAME="MediaItem" VALUE="'+MediaItem+'">');
writeln('<PARAM NAME="NoTicket" VALUE="1"> ');
writeln('<PARAM NAME="AutoPlay" VALUE="1"> ');
writeln('<PARAM NAME="RandomEnable" VALUE="1"> ');
writeln('<PARAM NAME="SkinName" VALUE="2003default_320"> ');
writeln('<PARAM NAME="SkinCodeBase"');
writeln('VALUE="http:\/\/www.example.com\/otherfile.sbd#Version=31015"> ');
writeln('<\/OBJECT><\/body><\/html>');
}}
</script>

MadamC

8:35 pm on Dec 13, 2004 (gmt 0)

10+ Year Member



Greg you're a genius =)

whoisgregg

1:51 am on Dec 14, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks for the kind words! I'll take that to mean it worked. :)