Det er højes forskelligt hvilke plugins der supporterer de der play og stop funktioner. (og også afhængigt af den browser der bruges). så du kan ikke rigtig stole på dem medmindre du har fuld kontrol med brugernes udstyr (fx på et intranet).
Så lav et alternativ. fx:
var musiVin = null;
function musicOn() { if ( document.melodi.play ) { // hvis funktionen findes document.melodi.play(); // bruger vi den } else { if ( !musiVin || !musiVin.document ) musiVin = window.open( \"\", \'musak\', \'width=100,height=65\' ); musiVin.document.open(\'text/html\',replace); musiVin.document.write(\'<embed name=\"melodi\" src=\"melodi.wav\" autostart=\"true\" loop=\"true\"></embed>\'); musiVin.document.close(); musiVin.focus() }
function musicOn() { if ( document.melodi.stop ) { // hvis funktionen findes document.melodi.stop(); // bruger vi den } else if ( musiVin && musiVin.document ) { musiVin.document.open(\'text/html\',replace); musiVin.document.write(\'stoppet\'); musiVin.document.close(); musiVin.blur(); } }
Ups. den } havde jeg glemt. den skal ftå for enden af den \'verste funktion, ikke helt forenden:
var musiVin = null;
function musicOn() { if ( document.melodi.play ) { // hvis funktionen findes document.melodi.play(); // bruger vi den } else { if ( !musiVin || !musiVin.document ) musiVin = window.open( \"\", \'musak\', \'width=100,height=65\' ); musiVin.document.open(\'text/html\',replace); musiVin.document.write(\'<embed name=\"melodi\" src=\"melodi.wav\" autostart=\"true\" loop=\"true\"></embed>\'); musiVin.document.close(); musiVin.focus() } }
function musicOff() { if ( document.melodi.stop ) { // hvis funktionen findes document.melodi.stop(); // bruger vi den } else if ( musiVin && musiVin.document ) { musiVin.document.open(\'text/html\',replace); musiVin.document.write(\'stoppet\'); musiVin.document.close(); musiVin.blur(); } }
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.