1

我有点麻烦,我创建了一个简单的网页来下载目录,我使用 javascript 来简化它,选择用户选择他们想要的目录,javascript 函数更新图像中的链接,以便用户可以下载不同的格式问题是,它在firefox和chrome中工作正常,但iexplore只是说“actLink未定义”(翻译自西班牙语actLink no esta definido)和actLink它是组合框更改时调用的函数,这就是我所拥有的:

调用函数的代码:

 <td align="center"><form id="form1" name="form1" method="post" action="">
<select name="cata_sel" id="cata_sel" onchange="actLink()">
  <option value="0" selected="selected">Seleccione el Catálogo...</option>
  <option value="Dependencia">Dependencias</option>
  <option value="Doc_of">Documentos Oficiales</option>
  <option value="EntidadFed">Entidades Federativas</option>
  <option value="Estado_Civil">Estado Civil</option>
  <option value="Grado_Escolar">Grado Escolar</option>
  <option value="Grado_Estudio">Grado de Estudio</option>
  <option value="LocYCP">Localidades y Codigos Postales</option>
  <option value="Municipio">Municipios</option>
  <option value="Nacionalidades">Nacionalidades</option>
  <option value="parentesco">Parentescos</option>
  <option value="Programas">Programas de Gobierno</option>
  <option value="Regiones">Regiones</option>
</select></label>
</form></td>

在 html 的 head 部分中定义的脚本

<script src="fnc1_0.js">
//<!--
window.onload = function(){//Ocultar todo el contenido
show_hide('descargas',0);
}

function actLink()
{
    if($('cata_sel').value!=0)
    {
    show_hide('descargas',0);
    $('dl_pdf').href="cat_dl/Cat_"+$('cata_sel').value+".pdf"
    $('dl_csv').href="cat_dl/Cat_"+$('cata_sel').value+".csv"
    $('dl_txt').href="cat_dl/Cat_"+$('cata_sel').value+".txt"
    $('dl_xls').href="cat_dl/Cat_"+$('cata_sel').value+".xls"
    $('dl_pdft').href="cat_dl/Cat_"+$('cata_sel').value+".pdf"
    $('dl_csvt').href="cat_dl/Cat_"+$('cata_sel').value+".csv"
    $('dl_txtt').href="cat_dl/Cat_"+$('cata_sel').value+".txt"
    $('dl_xlst').href="cat_dl/Cat_"+$('cata_sel').value+".xls"
    show_hide('descargas',1);
    }
    else
    show_hide('descargas',0);
}
//-->
</script>

'dl_' 元素是目录的链接。看起来像这样:*

<td><a id="dl_pdf" href="cat_dl/Cat_Dependencia.pdf" target="_blank"><img src="images/pdf-icon_resize.png" width="128" height="128" /></a></td>

the fnc1_0.js has a function to show/hide elements and a '$' named to substitute the getElementById() notation here it is if you need it:

function show_hide(id,act)
{//muestra u oculta divs, act=0:oculta,1:muestra,2:intermitente
//alert(id);
switch(act)
{
case 0:
$(id).style.display ='none'
break
case 1:
$(id).style.display ='block'
break
case 2:
$(id).style.display = ($(id).style.display == 'none') ? 'block' : 'none'; //damos un       atributo display:none que oculta el div
break
}
}

function $(variable)//reemplaza al getElementbyid
{
return document.getElementById(variable);
}

thats pretty much it, dont know whats wrong ie explore keeps saying that actLink its not defined whenever i select a catalog from the list!! please...hope you can help me!!!!!

4

1 回答 1

3

I think you problem is that you have code in a script tag that has a source, put your code in a script tag without the src attribute.

<script src="fnc1_0.js"></script>
<script>
//<!--
window.onload = function(){//Ocultar todo el contenido
show_hide('descargas',0);
}

function actLink()
{
    if($('cata_sel').value!=0)
    {
    show_hide('descargas',0);
    $('dl_pdf').href="cat_dl/Cat_"+$('cata_sel').value+".pdf"
    $('dl_csv').href="cat_dl/Cat_"+$('cata_sel').value+".csv"
    $('dl_txt').href="cat_dl/Cat_"+$('cata_sel').value+".txt"
    $('dl_xls').href="cat_dl/Cat_"+$('cata_sel').value+".xls"
    $('dl_pdft').href="cat_dl/Cat_"+$('cata_sel').value+".pdf"
    $('dl_csvt').href="cat_dl/Cat_"+$('cata_sel').value+".csv"
    $('dl_txtt').href="cat_dl/Cat_"+$('cata_sel').value+".txt"
    $('dl_xlst').href="cat_dl/Cat_"+$('cata_sel').value+".xls"
    show_hide('descargas',1);
    }
    else
    show_hide('descargas',0);
}
//-->
</script>
于 2013-04-18T23:10:44.900 回答