/    Sign up×
Community /Pin to ProfileBookmark

Javascript Browser Compatability

Can someone take a look at this? It works great in IE but doesn’t work in Firefox.

[code]
<SCRIPT LANGUAGE = “JavaScript”>
function change(url) {
var streamURL = url;
document.mediaPlayer.fileName = streamURL;
document.mediaPlayer.autostart = “1”;
}
</SCRIPT>
[code]

It is simply being called like: change(‘www.mysite.com/myvid.wmv’);

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@toicontienFeb 13.2006 — It looks to me like document.mediaPlayer.* is Interner Explorer only code. What does the rest of your HTML look like?
Copy linkTweet thisAlerts:
@cwilkeyauthorFeb 13.2006 — <!-- Video Player -->

<SCRIPT LANGUAGE = "JavaScript">

function change(url) {

var streamURL = url;

document.mediaPlayer.fileName = streamURL;

document.mediaPlayer.autostart = "1";

}

</SCRIPT>

<OBJECT

CLASSID="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95"

CODEBASE="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,5,715"

standby="Loading Microsoft® Windows® Media Player components..."

type="application/x-oleobject"

ID="mediaPlayer"

width="300"

height="250">

<param name="FileName" VALUE="/Streamer/playlist.php">

<?php // Only autostart if no cookie is set //

if ($_COOKIE['visitor'] == "visited"){

$value=0;

}

else{

$value = 1;

}

?>

<param name="autostart" value="<?php echo $value; ?>">

<param name="showdisplay" value="false">

<param name="transparentstart" value="true">

<param name="autorewind" value="false">

<param name="showcontrols" value="true">

<!-- Embedd the Player -->

<EMBED

SRC="http://proto.wrex.com//Streamer/playlist.php"

WIDTH="300"

HEIGHT="250"

AUTOSTART="<?php echo $value; ?>" TYPE="application/x-mplayer2"

PLUGINSPAGE="http://microsoft.com/windows/mediaplayer/en/download/"

ID="mediaPlayer"

Name="mediaPlayer" filename="/Streamer/playlist.php" showdisplay="false" transparentstart="true" autorewind="false" showcontrols="true">

</EMBED>

</OBJECT>

<!-- End Video Player -->
Copy linkTweet thisAlerts:
@toicontienFeb 13.2006 — Aha! The reason is because you've got the ID "mediaPlayer" in the document twice. An ID is an ID because it's only supposed to be in the document once.

Give the OBJECT and EMBED tags unique IDs, and then in your JavaScript, change the source for both tags.
×

Success!

Help @cwilkey 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 5.19,
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

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