Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/399.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript iframe内的下拉式onchange事件不起作用_Javascript_Iframe - Fatal编程技术网

Javascript iframe内的下拉式onchange事件不起作用

Javascript iframe内的下拉式onchange事件不起作用,javascript,iframe,Javascript,Iframe,出于各种复杂的原因,我有一个Joomla页面,其中有一个iFrame。iframe调用的页面是经典asp,其下拉列表如下所示: <select name="pulldown" onchange="nav_pulldown(this)"> <option value="?wherearewe=here">I want to go here</option> <option value="?wherearewe=there">I want to go

出于各种复杂的原因,我有一个Joomla页面,其中有一个iFrame。iframe调用的页面是经典asp,其下拉列表如下所示:

<select name="pulldown" onchange="nav_pulldown(this)">
<option value="?wherearewe=here">I want to go here</option>
<option value="?wherearewe=there">I want to go there</option>
</select>

我想去这里
我想去那里
JavaScript:

<script type="text/javascript"> 
<!-- //
function nav_pulldown(list) {
if (list.options[list.selectedIndex].value != "#"); {
top.document.location = list.options[list.selectedIndex].value;
}}
//-->
</script>

因此,用户更改下拉菜单,javascript提交表单。asp页面将获取该查询字符串,并根据所选内容呈现某些内容或其他内容。当页面在iframe之外自动呈现时(top.document有效时),这一切都可以正常工作。但我无法确定正确的名称或调用,以使下拉目标在更改时填充自身。我试过很多不同的方法


我可以控制这两个页面,Joomla和ASP。由于各种原因,查询字符串无法更改。iframe的名称当前是formframe,如果有必要的话。

根据注释,您需要使用
self.location
(或稍微冗余但等效的
self.document.location
)而不是
top.document.location


self
指javascript代码所在的文档<代码>顶部将引用最顶部的父文档。因此,当您不使用iframing页面时,
top
指的是
self
。但是,当您创建页面时,
top
指的是最顶层的父文档。

脚本是在asp页面上还是在iframe上?脚本在asp页面上。请将其放入iframe中。这应该可以做到。不会像在iframe中那样工作——您必须将“top.document.location”更改为“self.location”“将其放入iframe”,这不是一个选项。