user1623909
user1623909

Reputation: 11

Why isnt location.href() working?

I just want the new page to appear in an iframe on the current page instead of loading a whole new page.

Here's my code:

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);
}

This doesn't work in any browser. What am I doing wrong?

Upvotes: 0

Views: 189

Answers (6)

Chandra Sekhar Walajapet
Chandra Sekhar Walajapet

Reputation: 2554

You are returning false before you do anything with location.href.

Upvotes: 2

V.J.
V.J.

Reputation: 9590

use

window.location.href = "YourURL";

Upvotes: 0

Tarik
Tarik

Reputation: 2281

I think the correct syntax is:

location.href = gotoo;

Upvotes: 2

Danny Beckett
Danny Beckett

Reputation: 20806

Move return false; to the end, and use location.href like so:

location.href = gotoo;

Upvotes: 4

kapex
kapex

Reputation: 29999

You have a return false; in the middle of your function, so code after that return statement isn't executed.

Upvotes: 1

Marcus
Marcus

Reputation: 6849

location.href is an attribute rather than a function, use location.href = url instead.

Upvotes: 2

Related Questions