Ir para conteúdo

POWERED BY:

Arquivado

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

Pitag346

Script com '' Self ''

Recommended Posts

Olá amigos, primeira vez mechendo com JavaScript, e é o seguinte, não estou conseguindo adicionar o _self para abrir na mesma pagina...

Segue o Script abaixo:

<form name="menu1" >
	<div class="style1">
		<strong>
<select name="menu1" id="menu1" style="width: 277px; height: 23px" class="style5">
<option selected="">Escolha a Turma, para efetuar o post:</option>
<option value="turmas/turma1/manha/upload/index.php">Turma 1 - Manhã</option>
<option value="turmas/turma2/manha/upload/index.php">Turma 2 - Manhã</option>
<option value="turmas/turma1/tarde/upload/index.php">Turma 1 - Tarde </option>
<option value="turmas/turma2/tarde/upload/index.php">Turma 2 - Tarde </option>
<option value="turmas/turma1/noite/upload/index.php" Turma 1 - Noite </option>
<option value="turmas/turma2/noite/upload/index.php">Turma 2 - Noite </option>
<option value="turmas/barrobranco/upload/index.php">Barro Branco</option>
</select></strong>
<script type="text/javascript">
 var urlmenu = document.getElementById( 'menu1' );
 urlmenu.onchange = function() {
      window.open(  this.options[ this.selectedIndex ].value );
 };
</script>

 

Quero que abra na mesma pagina os links... espera que vocês me ajudem ! agradeço dês de já !

Compartilhar este post


Link para o post
Compartilhar em outros sites

http://www.w3schools.com/jsref/met_win_open.asp

 

Syntax

window.open(URL,name,specs,replace)

URL (Optional)

Specifies the URL of the page to open. If no URL is specified, a new window with about:blank is opened

 

name (Optional)

Specifies the target attribute or the name of the window. The following values are supported:

  • _blank - URL is loaded into a new window. This is default
  • _parent - URL is loaded into the parent frame
  • _self - URL replaces the current page
  • _top - URL replaces any framesets that may be loaded
  • name - The name of the window (Note: the name does not specify the title of the new window)

Compartilhar este post


Link para o post
Compartilhar em outros sites

O método mais simples:

 

Troque o código


window.open( this.options[ this.selectedIndex ].value );

 

Por esse


location.href( this.options[ this.selectedIndex ].value );

Compartilhar este post


Link para o post
Compartilhar em outros sites

A dica do @caioedut, está certinha, trocar .open, por location.href, só precisa ajustar um ponto:

 

.href é uma propriedade e não uma função, então o correto, e mais simples é::

document.location.href = this.value;

Compartilhar este post


Link para o post
Compartilhar em outros sites

 

A dica do @caioedut, está certinha, trocar .open, por location.href, só precisa ajustar um ponto:

 

.href é uma propriedade e não uma função, então o correto, e mais simples é::

document.location.href = this.value;

 

Só cuidado pro caso de o código estar sendo executado dentro de um iframe ein? (ok que ninguém mais usa, mas é bom avisar)

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.