/    Sign up×
Community /Pin to ProfileBookmark

Help with JavaScript + Embed src Code

I’m trying to have an avi file open up on a “Tv-Screen” within the same webpage (inside a single table cell, same spot) when a particular button/link is clicked (and changed accordingly whenever a different button/link is clicked). If you want to read how the whole thread started out [url=http://forums.webdeveloper.com/showthread.php?s=&postid=95810#post95810][b]Click Here[/b][/url]

Otherwise here’s the JavaScript “solution” I got [i](which unfortunately, i’m still too dumb to figure out the rest of the [b]body code[/b])[/i]: Hope someone can help me out.
[COLOR=royalblue]
Originally posted by PunkSktBrdr01
Well, if you want to use multiple videos, you could make a page for each one, or you could use JavaScript. I think this might work:

code:——————————————————————————–
<script type=”text/javascript”>
funtion changeChannel(channel) {
document.tv_screen.src = channel;
}

</script>
——————————————————————————–

Put that in the head of the page. Then add name=”tv_screen” to the embed tag. In each link that will change the video, change the href to ‘#’ and add onClick=”changeChannel(‘video file name’);”. I think that’s what you’re looking for. [/COLOR]

to post a comment
JavaScript

11 Comments(s)

Copy linkTweet thisAlerts:
@JonaSep 26.2003 — [font=arial][color=maroon]Something along these lines would probably work better and for more than just the IE browser...[/color][/font]

[font=monospace]

<script type="text/javascript"><!--

function changeChannel(channel){

if(document.getElementById){

document.getElementById("tv_screen").src=channel;

}

--></script>

</head>

<body>

<p><a href="jsDisabled.html" onclick="changeChannel('movie2.avi'); return false;">Movie 2</a> &middot;

<a href="jsDisabled.html" onclick="changeChannel('movie3.avi'); return false;">Movie 3</a></p>

<div>

<embed id="tv_screen" src="movie1.avi"></embed>

</div></body>

</html>

[/font]

[font=arial][color=maroon]jsDisabled.html should be a simple page that says the person has no JavaScript enabled, and therefore must select one of the following different pages to see the movies (and create a document with the src = whichever movie that corresponds with the selected page/link). That way those without JavaScript will be able to see the movies as well.[/color][/font]

[b][J]ona[/b]
Copy linkTweet thisAlerts:
@Four_of_FiveauthorSep 26.2003 — Thanks....but....well, it didn't work ?. Everytime I clicked on the "link"...it just launched the jsDisabled.html file, instead of playing the avi movie file on the embeded "tv screen".

I also tried "combining" some of the coding from the previous javascript but didn't work also...I changed the a href="#" and tried "bookmarking" the "tv screen" but didnt work either...just caused a nasty page fault.

Got any more ideas?
Copy linkTweet thisAlerts:
@JonaSep 26.2003 — [font=arial][color=maroon]The only time you'd be redirected to jsDisabled.html is if you didn't include the return false; part at the end, or your Javascript is disabled...[/color][/font]

[b][J]ona[/b]
Copy linkTweet thisAlerts:
@Four_of_FiveauthorSep 26.2003 — [i]Originally posted by Jona [/i]

[B][font=arial][color=maroon]The only time you'd be redirected to jsDisabled.html is if you didn't include the return false; part at the end, or your Javascript is disabled...[/color][/font]



[b][J]ona[/b] [/B]
[/QUOTE]


Nope. I'm pretty sure that i had included the [i]return false[/i] part..(coz I had basically copied&pasted the body part) and my JavaScript is enabled (in fact, my entire webpage(s) are riddled with them ? and most of em work fine...except for this one ? Darn, and it seemed so promising

And, I don't think there are/should be any conflicts with other scripts coz I tried your script on stand-alone...so it essentially was pretty much a virgin before I uhmm..messed it up :p
Copy linkTweet thisAlerts:
@JonaSep 26.2003 — [font=arial][color=maroon]Well, it's basically the same concept as the playMid() script on [url=http://geocities.com/god_loves_07/next_mid.html]this page[/url].[/color][/font]

[b][J]ona[/b]
Copy linkTweet thisAlerts:
@Four_of_FiveauthorSep 26.2003 — [i]Originally posted by Jona [/i]

[B][font=arial][color=maroon]Well, it's basically the same concept as the playMid() script on [url=http://geocities.com/god_loves_07/next_mid.html]this page[/url].[/color][/font]



[b][J]ona[/b] [/B]
[/QUOTE]


Hmmmm...well, in so far as cycling through different media titles, I guess you're right. But, getting a sound file to play and change into another one on click is quite different from displaying a video file in the same place (and size) on the same webpage.

Oh yeah, I forgot to mention in your suggested script i added: autostart="false" after the src="somemovie.avi"...in which case there's an error:

Line: 9 Char: 1

Error: Expected '}'

What do you think I should do?
Copy linkTweet thisAlerts:
@JonaSep 26.2003 — [font=arial][color=maroon]Ah, this is the second time I've made this mistake today! :mad: Here we go...[/color][/font]

[font=monospace]

<script type="text/javascript"><!--

function changeChannel(channel){

if(document.getElementById){

document.getElementById("tv_screen").src=channel;

} }

--></script>

</head>

<body>

<p><a href="jsDisabled.html" onclick="changeChannel('movie2.avi'); return false;">Movie 2</a> ·

<a href="jsDisabled.html" onclick="changeChannel('movie3.avi'); return false;">Movie 3</a></p>

<div>

<embed id="tv_screen" src="movie1.avi"></embed>

</div></body>

</html>

[/font]

[b][J]ona[/b]
Copy linkTweet thisAlerts:
@Four_of_FiveauthorSep 26.2003 — [i]Originally posted by Jona [/i]

[B][font=arial][color=maroon]Ah, this is the second time I've made this mistake today! :mad: Here we go...[/color][/font]



[font=monospace]

<script type="text/javascript"><!--

function changeChannel(channel){

if(document.getElementById){

document.getElementById("tv_screen").src=channel;

} }

--></script>

[b][J]ona[/b] [/B]
[/QUOTE]


hehehe :p sorry, but already done that...

Close but still No Dice ?

the good news though is that, it doesn't launch the jsdisabled.html file anymore...actually, when I click on any of the links...it doesnt do anything at all....arrrrgh..this is so :mad:

thanks so much for trying though...i think this calls for some Flash i think i found something similar to this at: [url=http://www.preloaded.com/v2/indexnorm.html]PRELOADED[/url]...the problem is that it ain't easy and the coding may kill me ?, that, and not all of my "clients" have Flash...
Copy linkTweet thisAlerts:
@JonaSep 26.2003 — [font=arial][color=maroon]I do not have three video files on my computer, so I cannot test the script on my computer; that is why I have been of little assistance. Good luck with whatever you decide to do.[/color][/font]

[b][J]ona[/b]
Copy linkTweet thisAlerts:
@Four_of_FiveauthorSep 26.2003 — Really? you have no .wma or avi files whatsover???

Well, I was just about to suggest that you try Quicktime movies (.MOV) and just rename them...then I stumbled upon another related problem: QTplayer doesn't seem to embed itself on the webpage ? unlike WindowsMedia

Oh well...the only thing i'm gonna do right now is catch some Zzzzzzzz
Copy linkTweet thisAlerts:
@JonaSep 26.2003 — [font=arial][color=maroon]Quicktime... Pff, I hate Quicktime. I downloaded Quicktime onto my Windows 98 computer, and I had to get rid of that 98 computer afterwards. It ruined the whole computer. I don't trust Apple with my PC's. :p



Anyways, embedding the video in Flash would actually be a very good alternative (makes it look much nicer, too).[/color]
[/font]

[b][J]ona[/b]
×

Success!

Help @Four_of_Five spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 4.28,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...