/    Sign up×
Community /Pin to ProfileBookmark

How and what in JavaScript

1- Iwrite the following line to embed/play an audio or a video file in an html document, and I would like to know please how could I control the playing (stop and replay it) applying JavaScript:
<EMBED name=”MUSIC” src=”echoes.mid” autostart=”true” hidden>

2- I would like to know through an example please how could I utilize the two methods: document.open(), and: document.close().

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@fredmvFeb 04.2004 — Welcome to the forums.[list=1]
  • [*]Assuming the embed is the first one in the document, it should be as easy as something like this:&lt;a href="#" onclick="document.embeds[0].play();"&gt;Pkay&lt;/a&gt;
    &lt;a href="#" onclick="document.embeds[0].stop();"&gt;Stop&lt;/a&gt;
  • [*]The [font=courier]document.open[/font] and [font=courier]document.clear[/font] methods are called automatically upon calling [font=courier]document.write[/font], rendering calling [font=courier]document.open[/font] useless. However, [font=courier]document.close[/font] shoud always be used to close the stream after you're done writing to the resource. Here's another example as you requested:&lt;script type="text/javascript"&gt;
    //&lt;![CDATA[
    var w = window.open('', '', 'height=300,width=300');

    <i> </i>with(w.document)
    <i> </i>{
    <i> </i> write('&lt;h1&gt;foo&lt;/h1&gt;');
    <i> </i> close();
    <i> </i>}
    //]]&gt;
    &lt;/script&gt;
  • [/list]
    ×

    Success!

    Help @Lotfi_Abdolhal 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.7,
    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,
    )...