Comunidad de diseño web y desarrollo en internet online

Problemas con "window.location.href"

Citar            
MensajeEscrito el 13 Ago 2008 01:20 am
BUeno es una web con php y sql tengo el problema k cuando digiten el index.php se redireccione un articulo ( sub pagina ) bueno funciona en IE6, pero en fiore fox,opera,IE7 no funcionan, quisiera k me ayuden en este caso , y gracias por la ayuda (F1)
aui les dejo el codigo

Código PHP :

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Documento sin t&iacute;tulo</title>
<link href="estilo.css" rel="stylesheet" type="text/css" />
<script language="javascript" src="stuHover.js"></script>
</head>

<body>
<table width="826" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <th colspan="2" class="encabezado" scope="col">&nbsp;</th>
  </tr>
  <tr>
    <td valign="top" class="fondo_menu">
   <div><img src="images/dcr_04.jpg" width="195" height="178" border="0px" /></div>
   
   <div class="menu_arriba"></div>
   <ul id="nav">
      <?php
         include("conec.php");
         $sql="SELECT * FROM menus where publicar=1 ORDER BY orden";
         $consulta=mysql_query($sql,$link);
         while ($menu=mysql_fetch_array($consulta)){
      ?>
      <li>
        <a href="#">&nbsp;&nbsp;&nbsp;&nbsp;<?php echo $menu[2]; ?></a>
        <ul><?php
            $id_menu=$menu[0];
            $sql_1="select * from articulos where id_menu='$id_menu' and publicar=1 order by orden";
            $consulta_1=mysql_query($sql_1,$link);
            while ($articulo=mysql_fetch_array($consulta_1)){
            $id_articulo=$articulo[0];
            $contenido=$articulo[5];
      ?>
      <li><a <?php echo "href='index.php?articulo=$id_articulo'"?>> 
               <?php 
               echo $articulo[2];
               ?>
      </a></li><?php
               }
               mysql_free_result($consulta_1);
      ?></ul>
      </li>
      <?php
         }
         mysql_free_result($consulta);
      ?>
   </ul>
   <div class="pie_menu"></div>   
      
   </td>
    <td rowspan="2" valign="top" class="fondo_cont">
      <div class="part01_2"></div>
      <div class="contenido">
      
         <?php
            include("conec.php");
            if ($_GET){
               $articulo=$_GET["articulo"];
               $sql_2="select titulo_articulo,contenido from articulos where id_articulo=$articulo";
               $consulta_2=mysql_query($sql_2,$link);
               while ($contenido=mysql_fetch_array($consulta_2)){
                  $titulo=$contenido[0];
                  echo "<h3>".$titulo."</h3>";
                  $texto=$contenido[1];
                  echo $texto;
               }
               mysql_free_result($consulta_2);
               mysql_close($link);
            }
            else {
               echo "<script>window.location.href('index.php?articulo=41')</script>";-------> no Funciona
            }
         ?>
      </div>      </td>
  </tr>
  <tr>
    <td valign="top" class="fondo_menu">
   </td>
  </tr>
  <tr>
    <td class="menu_inf01"></td>
    <td class="menu_inf02"></td>
  </tr>
  <tr>
    <td colspan="2" align="center" valign="middle" bgcolor="#FFFFFF">bla blabla jejejejje</td>
  </tr>
</table>
</body>
</html>

Por jackstark

1 de clabLevel



 

firefox
Citar            
MensajeEscrito el 13 Ago 2008 03:31 am
Amigo,

href es una propiedad del objeto location no un método como lo estas utilizando.

cambia :

Código Javascript :

window.location.href('index.php?articulo=41');


por:

Código Javascript :

window.location.href = 'index.php?articulo=41';


Quedo pendiente..

Por johnx

7 de clabLevel



Genero:Masculino  

firefox
Citar            
MensajeEscrito el 14 Ago 2008 11:37 am
Eso es.

Creo, que lo estás confundiendo con "replace", que se usa:

Código :

location.replace('index.php?articulo=41')
(y sustituye la página, también en el historial)

Por El Oso Amoroso

Claber

1780 de clabLevel

6 tutoriales

 

Madrid, España, Europa, Eurasia, La Tierra, Sist.Solar, Vía Láctea, UNIVERSO

firefox

 

Cristalab BabyBlue v4 + V4 © 2011 Cristalab
Powered by ClabEngines v4, HTML5, love and ponies.