Javascript 为什么location.href()不起作用?
我只希望新页面出现在当前页面的Javascript 为什么location.href()不起作用?,javascript,location-href,Javascript,Location Href,我只希望新页面出现在当前页面的iframe中,而不是加载整个新页面 这是我的密码: function salabim(id){ var gotoo; var objid = document.getElementById("pgMaster"); new Effect.Shake(id); return false; gotoo=id+".html"; objid.src=gotoo; location.href(gotoo); }
iframe
中,而不是加载整个新页面
这是我的密码:
function salabim(id){
var gotoo;
var objid = document.getElementById("pgMaster");
new Effect.Shake(id);
return false;
gotoo=id+".html";
objid.src=gotoo;
location.href(gotoo);
}
这在任何浏览器中都不起作用。我做错了什么?
location.href
是一个属性而不是一个函数,请改用location.href=url
。您的返回值为false代码>在函数的中间,所以在返回语句之后没有执行代码。< /P> < P>移动<代码>返回false;结束,然后使用location.href
如下所示:
location.href = gotoo;
我认为正确的语法是:
location.href = gotoo;
在使用location.href
执行任何操作之前,您将返回false
window.location.href = "YourURL";
下面的代码“return false;”将不会执行。要求讲师在函数末尾添加代码。所以他就这么做了,pgMaster
是iframe的ID吗?正如nelson提到的,返回后的所有内容都是false;永远不会被执行。放回假;就在您的location.href(gotoo)之后;在}//结束salabim之前。