The new forums will be named Coin Return (based on the most recent vote)! You can check on the status and timeline of the transition to the new forums here.
The Guiding Principles and New Rules document is now in effect.

IE6, <embed> tags and Javascript

SeñorAmorSeñorAmor !!!Registered User regular
edited June 2007 in Help / Advice Forum
I am making a new soccer-themed website for my boss. He's a coach and wants to have soccer-related YouTube videos embedded, for his kids to watch. Rather than have 10 clips embedded, I have a list of all the clips. Upon clicking each link, the appropriate video will load on the page.

I have accomplished this by using Javascript's .innerHTML function to rewrite only the div that contains the movie. This way the users don't have to reload the entire page. It functions fine on FF, Opera and IE7, but not in IE6, and I can't figure out why. I have done some testing and IE6 is rewriting the div contents fine, but as soon as I try to rewrite and include an <embed> tag, IE6 does nothing.

I'm not sure what's going wrong and any help would be much appreciated.

Relevant code:

[HTML File]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title></title>
<link rel="stylesheet" type="text/css" href="css/general.css" />
<script language="javascript" type="text/javascript" src="includes/video.js"></script>
</head>

<body>
<div id="main">
	<div id="subheader">
		<img src="images/header_videos.gif" width="110" height="45" alt="Videos" title="Videos" />
	</div>

	<div id="video_list">
		<div id="video_list_header">
			Click the links below<br /> to watch a video.
		</div>
		
		<div id="video_list_text">
			<a href="#view" onclick="play_video('FU4Edue4n9A')">Brazilian Soccer Schools #1</a><br />
			<a href="#view" onclick="play_video('mBOUZmtx6JM')">Great Goalkeeper Moments</a><br />
			<a href="#view" onclick="play_video('M3S-mOvN2Xs')">Soccer Skills</a>
		</div>
	</div>

	<a name="view" />
	<div id="video">
		<div style="text-align: center; padding-top: 75px; color: #FFFFFF;">Please select a video from the list on the left.</div>
	</div>
</div>
</body>
</html>

[video.js]
function play_video(id)
{

	document.getElementById('video').innerHTML = 'Loading video...  One moment please.';
	
	var embed_text = '<object width="425" height="350">' +
		'<param name="movie" value="http://www.youtube.com/v/{MOVIE_ID}"></param>' +
		'<param name="wmode" value="transparent"></param>' +
		'<embed src="http://www.youtube.com/v/{MOVIE_ID}" type="application/x-shockwave-flash" wmode="transparent" width="425" height="350"></embed>' +
	'</object>';
	
	embed_text = embed_text.replace(/{MOVIE_ID}/g, id);
	
	document.getElementById('video').innerHTML = embed_text;
}

SeñorAmor on

Posts

  • SeñorAmorSeñorAmor !!! Registered User regular
    edited June 2007
    Anyone?

    SeñorAmor on
  • JaninJanin Registered User regular
    edited June 2007
    Have you tried using DOM methods instead of manually creating innerHTML? Here's a quick guide to using the DOM to traverse and manipulate a table, it should be easy enough to adapt to embeds. You could also try using the <object> element.

    Janin on
    [SIGPIC][/SIGPIC]
  • JasconiusJasconius sword criminal mad onlineRegistered User regular
    edited June 2007
    All I know is that specifically IE6 handles InnerHTML differently than FireFox, and the most recent version of IE.

    Did you view your source so see if IE6 was converting any of your symbols like " or < to their web-safe counterparts?

    The company I work for uses a Rich Text editor that uses InnerHTML and in IE6 it constantly rewrites special characters like TM to &trade automatically.

    --

    I don't see anything wrong with your JavaScript.

    Solutions other than InnerHTML:


    Iframe it in. Yes, evil, but this is a small audience site, and it still works in most major browsers

    Modify SWFObject's embed to allow you to rewrite the target DIV with an onclick event handler? so.write is just a function call that rewrites the contents of a DIV layer with an appropriate <embed>. I don't see any reason why it can't be executed on an event handler, though I have not tried it.

    Jasconius on
    this is a discord of mostly PA people interested in fighting games: https://discord.gg/DZWa97d5rz

    we also talk about other random shit and clown upon each other
Sign In or Register to comment.