HTML/Javascript people i need your help!

Ok basically… Here is what i have. I have a website, and on this website i have a handy little page called videos.html Now I have a link pointed to vd_001.avi which when clicked asks if you want to save or open the file. Now i don’t want it to download automatically i want windows media player to open and start streaming the file once its clicked. I know i can embed the file into my page but i don’t not want to create 30 different pages for each file. I have used a Javascript to automatically open a picture up in a new automatically resized window but is that possible with embedded content such as a video?

Why would you have to create 30 pages for each file? Or do you mean you have 30 videos, and you don’t want to create one page for each file? I’m confused.

Yes i have several videos and i dont want to embed them all in one page obivisouly so i want the standalone WMP to open them and start to steam so i dont have to creat 30 diffenernt pages each one having embded content.

Okay. Probably the easiest way to do this is, you can create the links to your embed HTML pages saying <A href=‘embed.html?vd_001.avi’>Click here for video 1</A>

Then, in the embed.html, at the spot where you want it to insert the vd_001.avi name from the link, use javascript code like this:



<SCRIPT language='javascript'>

s = document.search
s = s.substring(1, s.length - 1)
document.write (s)

</SCRIPT>


What the code is doing is this: document.search gives you the portion of the current URL that is on and after a ? (if any) and before a # anchor. In this case, it’s ?vd_001.avi

The substring call should eliminate the ? and just leave the vd_001.avi

document.write will include that filename in the HTML source that the browser is rendering, as if it were in the HTML file from the start.

Depending on how the embed stuff works, you might need to document.write the entire tag instead of just the name, you can do that with “<tag whatever=’” + s + “>” or something like that

Hope that this helps start you off.

Thanks, i will give that a try. I will not need to create a page for each one correct? Java script is doing it on the fly?

EDIT: After looking at this it seems i will have to create an embed1 embed 2 embed 3 for every video files? Is there a way just to make WMP open and load the file when clicked?

Nah, what he’s saying is that your links would be like…



<a href=embed.html?avi1.avi>Video 1</a>
<a href=embed.html?avi2.avi>Video 2</a>
<a href=embed.html?avi3.avi>Video 3</a>


The Javascript on the embed.html page (the one single page) will take the file name from after the ? and drop it into your embed code.

It’s a neato way to make a dynamic Web page without ASP or PHP.

Well I don’t know if that helped the OP, but it’s sure going to help me in future! Thanks.

Chris, seems you write the HTML for streaming AVI once, and have a portion of the HTML that is written by JavaScript that includes the “substring” variable to insert the filename dynamically.