Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

pedrotavares.pt

[Resolvido] Mudar Valor URL de Objecto com Javascript

Recommended Posts

Boa Tarde,

 

Tenho a seguinte página:

 

 

<html>
<head>
<title>PFST@line</title>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
</head>

<body>
<object id="radioplayer" classid="clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6" width="255" height="75" align="middle">
 <param name="URL" value="mms://195.23.102.196/bestrockcbr96" ref>
 <param name="rate" value="1">
 <param name="balance" value="0">
 <param name="currentPosition" value="0">
 <param name="defaultFrame" value>
 <param name="playCount" value="1">
 <param name="autoStart" value="-1">
 <param name="currentMarker" value="0">
 <param name="invokeURLs" value="-1">
 <param name="baseURL" value>
 <param name="volume" value="100">
 <param name="mute" value="0">
 <param name="uiMode" value="mini">
 <param name="stretchToFit" value="-1">
 <param name="windowlessVideo" value="0">
 <param name="enabled" value="-1">
 <param name="enableContextMenu" value="-1">
 <param name="fullScreen" value="0">
 <param name="SAMIStyle" value>
 <param name="SAMILang" value>
 <param name="SAMIFilename" value>
 <param name="captioningID" value>
 <param name="enableErrorDialogs" value="0">
 <param name="_cx" value="6747">
 <param name="_cy" value="1984">
 </object>
<br>
<form name="addresses">
<select name="list" onChange="update()">
<option value="radio.html" selected>Escolha a sua rádio...
<option value="antena1.asx">Antena 1
<option value="antena2.asx">Antena 2
<option value="antena3.asx">Antena 3
<option value="mms://195.23.102.196/bestrockcbr96">Best Rock FM
</select>
<a href="updatelink">Ouvir Rádio</a>
</form>
<script language="javascript">
pos = 9999;
for(num=0;num<document.links.length;num++) {
if (document.links[num].href.indexOf("updatelink") != -1) {
pos = num;
num = 5000;
   }
}
function update() {
if (pos!=9999) {
sel = document.addresses.list.selectedIndex;
document.links[pos].href = document.addresses.list[sel].value;
   }
}
update();
</script>
</body>

</html>

 

Como faço para mudar a value URL do radioplayer com o script que aqui tenho?

 

Agredeço a ajuda!

Compartilhar este post


Link para o post
Compartilhar em outros sites

Olá Ted!

 

Eu tenho a questão mal feita, de facto!

 

O objecto é um leitor de rádio com ligação a uma rádio!

O formulário é um formulário que eu estava a usar para navegar entre páginas que continham, cada uma delas, a sua própria rádio!

Basicamente, o que eu quero fazer é alterar o script (que pertence ao formulário) para que o leitor de rádio encontre uma nova URL especificada pela escolha da option.

<option value="mms://195.23.102.196/bestrockcbr96" selected>Escolha a sua rádio... 
<option value="mms://195.23.102.196/cidadecbr96">Cidade
<option value="mms://stream.radio.com.pt/ROLI-ENC-133">Festival 
<option value="http://www.radios.com.br/asx/103fmser-br.asx">103 Fm Aracaju
<option value="mms://195.23.102.196/bestrockcbr96">Best Rock FM
Já estive a ver, e acho que existe qualquer coisa relacionada com o GetElementById. Mas não sei como o fazer!

Cumprimentos!

Pedro

Compartilhar este post


Link para o post
Compartilhar em outros sites

Assim:

<html>
<head>
	<title>PFST@line</title>
	<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">

<script type="text/javascript">
function muda( valor)
{
	var radio = '<object classid="clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6" width="255" height="75" align="middle">'+
		'<param name="URL" value="'+valor+'" ref>'+
		'<param name="rate" value="1">'+
		'<param name="balance" value="0">'+
		'<param name="currentPosition" value="0">'+
		'<param name="defaultFrame" value>'+
		'<param name="playCount" value="1">'+
		'<param name="autoStart" value="-1">'+
		'<param name="currentMarker" value="0">'+
		'<param name="invokeURLs" value="-1">'+
		'<param name="baseURL" value>'+
		'<param name="volume" value="100">'+
		'<param name="mute" value="0">'+
		'<param name="uiMode" value="mini">'+
		'<param name="stretchToFit" value="-1">'+
		'<param name="windowlessVideo" value="0">'+
		'<param name="enabled" value="-1">'+
		'<param name="enableContextMenu" value="-1">'+
		'<param name="fullScreen" value="0">'+
		'<param name="SAMIStyle" value>'+
		'<param name="SAMILang" value>'+
		'<param name="SAMIFilename" value>'+
		'<param name="captioningID" value>'+
		'<param name="enableErrorDialogs" value="0">'+
		'<param name="_cx" value="6747">'+
		'<param name="_cy" value="1984">'+
		'</object>';
	document.getElementById('radioplayer').innerHTML = radio;
}
window.onload = function(){
	muda('mms://195.23.102.196/bestrockcbr96');
}
</script>
</head>

<body>
	<div id="radioplayer"></div>
	<br>
	<form name="addresses">
		<select name="list" onchange="muda( this.value )">
			<option value="mms://195.23.102.196/bestrockcbr96" selected="selected">Escolha a sua rádio... </option>
			<option value="mms://195.23.102.196/cidadecbr96">Cidade</option>
			<option value="mms://stream.radio.com.pt/ROLI-ENC-133">Festival </option>
			<option value="http://www.radios.com.br/asx/103fmser-br.asx">103 Fm Aracaju</option>
			<option value="mms://195.23.102.196/bestrockcbr96">Best Rock FM</option>
		</select>
	</form><!-- /addresses -->
</body>
</html>

Compartilhar este post


Link para o post
Compartilhar em outros sites

É isso mesmo! Funciona direitinho!

Eu, como não estava a conseguir mudar o valor da URL, acabei, esta noite, por criar uma alternativa: multiplas funções:

<html>

<head>
<title>PFST@line</title>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="Copyright" content="Pedro Filipe Silva Tavares">
<script language = "javascript">
<!--
function loadVideo(){document.getElementById('divVideo').innerHTML = '<object classid="clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6" width="255" height="75" align="middle"><param name="URL" value="antena1.asx" ref><param name="rate" value="1"><param name="balance" value="0"><param name="currentPosition" value="0"><param name="defaultFrame" value><param name="playCount" value="1"><param name="autoStart" value="-1"><param name="currentMarker" value="0"><param name="invokeURLs" value="-1"><param name="baseURL" value><param name="volume" value="100"><param name="mute" value="0"><param name="uiMode" value="mini"><param name="stretchToFit" value="-1"><param name="windowlessVideo" value="0"><param name="enabled" value="-1"><param name="enableContextMenu" value="-1"><param name="fullScreen" value="0"><param name="SAMIStyle" value><param name="SAMILang" value><param name="SAMIFilename" value><param name="captioningID" value><param name="enableErrorDialogs" value="0"><param name="_cx" value="6747"><param name="_cy" value="1984"></object>';}
function loadVideo0(){document.getElementById('divVideo').innerHTML = '<object classid="clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6" width="255" height="75" align="middle"><param name="URL" value="antena2.asx" ref><param name="rate" value="1"><param name="balance" value="0"><param name="currentPosition" value="0"><param name="defaultFrame" value><param name="playCount" value="1"><param name="autoStart" value="-1"><param name="currentMarker" value="0"><param name="invokeURLs" value="-1"><param name="baseURL" value><param name="volume" value="100"><param name="mute" value="0"><param name="uiMode" value="mini"><param name="stretchToFit" value="-1"><param name="windowlessVideo" value="0"><param name="enabled" value="-1"><param name="enableContextMenu" value="-1"><param name="fullScreen" value="0"><param name="SAMIStyle" value><param name="SAMILang" value><param name="SAMIFilename" value><param name="captioningID" value><param name="enableErrorDialogs" value="0"><param name="_cx" value="6747"><param name="_cy" value="1984"></object>';}
function loadVideo1(){document.getElementById('divVideo').innerHTML = '<object classid="clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6" width="255" height="75" align="middle"><param name="URL" value="antena3.asx" ref><param name="rate" value="1"><param name="balance" value="0"><param name="currentPosition" value="0"><param name="defaultFrame" value><param name="playCount" value="1"><param name="autoStart" value="-1"><param name="currentMarker" value="0"><param name="invokeURLs" value="-1"><param name="baseURL" value><param name="volume" value="100"><param name="mute" value="0"><param name="uiMode" value="mini"><param name="stretchToFit" value="-1"><param name="windowlessVideo" value="0"><param name="enabled" value="-1"><param name="enableContextMenu" value="-1"><param name="fullScreen" value="0"><param name="SAMIStyle" value><param name="SAMILang" value><param name="SAMIFilename" value><param name="captioningID" value><param name="enableErrorDialogs" value="0"><param name="_cx" value="6747"><param name="_cy" value="1984"></object>';}
function loadVideo2(){document.getElementById('divVideo').innerHTML = '<object classid="clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6" width="255" height="75" align="middle"><param name="URL" value="mms://195.23.102.196/bestrockcbr96" ref><param name="rate" value="1"><param name="balance" value="0"><param name="currentPosition" value="0"><param name="defaultFrame" value><param name="playCount" value="1"><param name="autoStart" value="-1"><param name="currentMarker" value="0"><param name="invokeURLs" value="-1"><param name="baseURL" value><param name="volume" value="100"><param name="mute" value="0"><param name="uiMode" value="mini"><param name="stretchToFit" value="-1"><param name="windowlessVideo" value="0"><param name="enabled" value="-1"><param name="enableContextMenu" value="-1"><param name="fullScreen" value="0"><param name="SAMIStyle" value><param name="SAMILang" value><param name="SAMIFilename" value><param name="captioningID" value><param name="enableErrorDialogs" value="0"><param name="_cx" value="6747"><param name="_cy" value="1984"></object>';}
function loadVideo3(){document.getElementById('divVideo').innerHTML = '<object classid="clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6" width="255" height="75" align="middle"><param name="URL" value="mms://195.23.102.196/cidadecbr96" ref><param name="rate" value="1"><param name="balance" value="0"><param name="currentPosition" value="0"><param name="defaultFrame" value><param name="playCount" value="1"><param name="autoStart" value="-1"><param name="currentMarker" value="0"><param name="invokeURLs" value="-1"><param name="baseURL" value><param name="volume" value="100"><param name="mute" value="0"><param name="uiMode" value="mini"><param name="stretchToFit" value="-1"><param name="windowlessVideo" value="0"><param name="enabled" value="-1"><param name="enableContextMenu" value="-1"><param name="fullScreen" value="0"><param name="SAMIStyle" value><param name="SAMILang" value><param name="SAMIFilename" value><param name="captioningID" value><param name="enableErrorDialogs" value="0"><param name="_cx" value="6747"><param name="_cy" value="1984"></object>';}
function loadVideo4(){document.getElementById('divVideo').innerHTML = '<object classid="clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6" width="255" height="75" align="middle"><param name="URL" value="djprtfm.asx" ref><param name="rate" value="1"><param name="balance" value="0"><param name="currentPosition" value="0"><param name="defaultFrame" value><param name="playCount" value="1"><param name="autoStart" value="-1"><param name="currentMarker" value="0"><param name="invokeURLs" value="-1"><param name="baseURL" value><param name="volume" value="100"><param name="mute" value="0"><param name="uiMode" value="mini"><param name="stretchToFit" value="-1"><param name="windowlessVideo" value="0"><param name="enabled" value="-1"><param name="enableContextMenu" value="-1"><param name="fullScreen" value="0"><param name="SAMIStyle" value><param name="SAMILang" value><param name="SAMIFilename" value><param name="captioningID" value><param name="enableErrorDialogs" value="0"><param name="_cx" value="6747"><param name="_cy" value="1984"></object>';}
function loadVideo5(){document.getElementById('divVideo').innerHTML = '<object classid="clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6" width="255" height="75" align="middle"><param name="URL" value="mms://stream.radio.com.pt/ROLI-ENC-411" ref><param name="rate" value="1"><param name="balance" value="0"><param name="currentPosition" value="0"><param name="defaultFrame" value><param name="playCount" value="1"><param name="autoStart" value="-1"><param name="currentMarker" value="0"><param name="invokeURLs" value="-1"><param name="baseURL" value><param name="volume" value="100"><param name="mute" value="0"><param name="uiMode" value="mini"><param name="stretchToFit" value="-1"><param name="windowlessVideo" value="0"><param name="enabled" value="-1"><param name="enableContextMenu" value="-1"><param name="fullScreen" value="0"><param name="SAMIStyle" value><param name="SAMILang" value><param name="SAMIFilename" value><param name="captioningID" value><param name="enableErrorDialogs" value="0"><param name="_cx" value="6747"><param name="_cy" value="1984"></object>';}
function loadVideo6(){document.getElementById('divVideo').innerHTML = '<object classid="clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6" width="255" height="75" align="middle"><param name="URL" value="hsbox.asx" ref><param name="rate" value="1"><param name="balance" value="0"><param name="currentPosition" value="0"><param name="defaultFrame" value><param name="playCount" value="1"><param name="autoStart" value="-1"><param name="currentMarker" value="0"><param name="invokeURLs" value="-1"><param name="baseURL" value><param name="volume" value="100"><param name="mute" value="0"><param name="uiMode" value="mini"><param name="stretchToFit" value="-1"><param name="windowlessVideo" value="0"><param name="enabled" value="-1"><param name="enableContextMenu" value="-1"><param name="fullScreen" value="0"><param name="SAMIStyle" value><param name="SAMILang" value><param name="SAMIFilename" value><param name="captioningID" value><param name="enableErrorDialogs" value="0"><param name="_cx" value="6747"><param name="_cy" value="1984"></object>';}
function loadVideo7(){document.getElementById('divVideo').innerHTML = '<object classid="clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6" width="255" height="75" align="middle"><param name="URL" value="mms://195.23.102.196/m80cbr96" ref><param name="rate" value="1"><param name="balance" value="0"><param name="currentPosition" value="0"><param name="defaultFrame" value><param name="playCount" value="1"><param name="autoStart" value="-1"><param name="currentMarker" value="0"><param name="invokeURLs" value="-1"><param name="baseURL" value><param name="volume" value="100"><param name="mute" value="0"><param name="uiMode" value="mini"><param name="stretchToFit" value="-1"><param name="windowlessVideo" value="0"><param name="enabled" value="-1"><param name="enableContextMenu" value="-1"><param name="fullScreen" value="0"><param name="SAMIStyle" value><param name="SAMILang" value><param name="SAMIFilename" value><param name="captioningID" value><param name="enableErrorDialogs" value="0"><param name="_cx" value="6747"><param name="_cy" value="1984"></object>';}
function loadVideo8(){document.getElementById('divVideo').innerHTML = '<object classid="clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6" width="255" height="75" align="middle"><param name="URL" value="mms://stream2.mega.fm/MegaFM" ref><param name="rate" value="1"><param name="balance" value="0"><param name="currentPosition" value="0"><param name="defaultFrame" value><param name="playCount" value="1"><param name="autoStart" value="-1"><param name="currentMarker" value="0"><param name="invokeURLs" value="-1"><param name="baseURL" value><param name="volume" value="100"><param name="mute" value="0"><param name="uiMode" value="mini"><param name="stretchToFit" value="-1"><param name="windowlessVideo" value="0"><param name="enabled" value="-1"><param name="enableContextMenu" value="-1"><param name="fullScreen" value="0"><param name="SAMIStyle" value><param name="SAMILang" value><param name="SAMIFilename" value><param name="captioningID" value><param name="enableErrorDialogs" value="0"><param name="_cx" value="6747"><param name="_cy" value="1984"></object>';}
function loadVideo9(){document.getElementById('divVideo').innerHTML = '<object classid="clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6" width="255" height="75" align="middle"><param name="URL" value="mxfm.asx" ref><param name="rate" value="1"><param name="balance" value="0"><param name="currentPosition" value="0"><param name="defaultFrame" value><param name="playCount" value="1"><param name="autoStart" value="-1"><param name="currentMarker" value="0"><param name="invokeURLs" value="-1"><param name="baseURL" value><param name="volume" value="100"><param name="mute" value="0"><param name="uiMode" value="mini"><param name="stretchToFit" value="-1"><param name="windowlessVideo" value="0"><param name="enabled" value="-1"><param name="enableContextMenu" value="-1"><param name="fullScreen" value="0"><param name="SAMIStyle" value><param name="SAMILang" value><param name="SAMIFilename" value><param name="captioningID" value><param name="enableErrorDialogs" value="0"><param name="_cx" value="6747"><param name="_cy" value="1984"></object>';}
function loadVideo10(){document.getElementById('divVideo').innerHTML = '<object classid="clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6" width="255" height="75" align="middle"><param name="URL" value="ntfm.asx" ref><param name="rate" value="1"><param name="balance" value="0"><param name="currentPosition" value="0"><param name="defaultFrame" value><param name="playCount" value="1"><param name="autoStart" value="-1"><param name="currentMarker" value="0"><param name="invokeURLs" value="-1"><param name="baseURL" value><param name="volume" value="100"><param name="mute" value="0"><param name="uiMode" value="mini"><param name="stretchToFit" value="-1"><param name="windowlessVideo" value="0"><param name="enabled" value="-1"><param name="enableContextMenu" value="-1"><param name="fullScreen" value="0"><param name="SAMIStyle" value><param name="SAMILang" value><param name="SAMIFilename" value><param name="captioningID" value><param name="enableErrorDialogs" value="0"><param name="_cx" value="6747"><param name="_cy" value="1984"></object>';}
function loadVideo11(){document.getElementById('divVideo').innerHTML = '<object classid="clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6" width="255" height="75" align="middle"><param name="URL" value="mms://emissao.radionovaera.pt/RNE" ref><param name="rate" value="1"><param name="balance" value="0"><param name="currentPosition" value="0"><param name="defaultFrame" value><param name="playCount" value="1"><param name="autoStart" value="-1"><param name="currentMarker" value="0"><param name="invokeURLs" value="-1"><param name="baseURL" value><param name="volume" value="100"><param name="mute" value="0"><param name="uiMode" value="mini"><param name="stretchToFit" value="-1"><param name="windowlessVideo" value="0"><param name="enabled" value="-1"><param name="enableContextMenu" value="-1"><param name="fullScreen" value="0"><param name="SAMIStyle" value><param name="SAMILang" value><param name="SAMIFilename" value><param name="captioningID" value><param name="enableErrorDialogs" value="0"><param name="_cx" value="6747"><param name="_cy" value="1984"></object>';}
function loadVideo12(){document.getElementById('divVideo').innerHTML = '<object classid="clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6" width="255" height="75" align="middle"><param name="URL" value="ocnpcf.asx" ref><param name="rate" value="1"><param name="balance" value="0"><param name="currentPosition" value="0"><param name="defaultFrame" value><param name="playCount" value="1"><param name="autoStart" value="-1"><param name="currentMarker" value="0"><param name="invokeURLs" value="-1"><param name="baseURL" value><param name="volume" value="100"><param name="mute" value="0"><param name="uiMode" value="mini"><param name="stretchToFit" value="-1"><param name="windowlessVideo" value="0"><param name="enabled" value="-1"><param name="enableContextMenu" value="-1"><param name="fullScreen" value="0"><param name="SAMIStyle" value><param name="SAMILang" value><param name="SAMIFilename" value><param name="captioningID" value><param name="enableErrorDialogs" value="0"><param name="_cx" value="6747"><param name="_cy" value="1984"></object>';}
//-->
</script>
</head>

<body>

<div id="divVideo" style="width:255px; height:75px"></div><br>
<form name="addresses" align="center">
<select name="list" onChange="update()">
<option value="teste.html" selected>Escolha a sua rádio...
<option value="javascript:loadVideo();">Antena 1
<option value="javascript:loadVideo0();">Antena 2
<option value="javascript:loadVideo1();">Antena 3
<option value="javascript:loadVideo2();">Best Rock FM
<option value="javascript:loadVideo3();">Cidade FM
<option value="javascript:loadVideo4();">DJ Porto FM
<option value="javascript:loadVideo5();">Hiper FM
<option value="javascript:loadVideo6();">HouseBox
<option value="javascript:loadVideo7();">M 80
<option value="javascript:loadVideo8();">Mega FM
<option value="javascript:loadVideo9();">Mix FM
<option value="javascript:loadVideo10();">Noite FM
<option value="javascript:loadVideo11();">Nova Era
<option value="javascript:loadVideo12();">Oceano Pacífico (RFM)
</select>
<a href="updatelink">Ouvir Rádio</a>
<script language="javascript">
pos = 9999;
for(num=0;num<document.links.length;num++) {
if (document.links[num].href.indexOf("updatelink") != -1) {
pos = num;
num = 5000;
   }
}
function update() {
if (pos!=9999) {
sel = document.addresses.list.selectedIndex;
document.links[pos].href = document.addresses.list[sel].value;
   }
}
update();
</script>
</form>
</body>
</html>
Como é obvio, a página ia ficar mais carregada, em seguida ia tentar passar tudo para um .js externo.

Mas a sua solução era exactamente aquilo que eu andava à procura!

Obrigado, Bruno!

Cumprimentos, Ted.

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.