/    Sign up×
Community /Pin to ProfileBookmark

JS to open link + jump to page #anchor

I am doing an IDX portal (idx=real estate home search page).

I am using a few different platforms that communicate with iframes, its a little murky, but its stable.

When I click a link on my parent page, I want it to jump to a page anchor just above the iframe as it loads the href content. I’m not the best at JS, but here is my solution, and its not working. Help?

my function-

[CODE]<script type=”text/javascript”>
function headAnchor()
{
window.location.hash=”head”;
}
</script>[/CODE]

page anchor-

[CODE]<a name=”#head”>[/CODE]

link-

[code]<a href=”http://my.dom/mylink.php” target=”iframe” onclick=”headAnchor()”>[/code]

What am i missing?

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@KGDeemauthorMay 09.2013 — Oh, it works in IE (but only with compatibility view turned on). but not firefox or chrome. Whats the FF/C fix?
Copy linkTweet thisAlerts:
@PadonakMay 09.2013 — <a name="head"></a> w/o '[B]#[/B]' ----> this is the point where the page will be scrolled to

<a href="#head">head</a> -----> this is clicked to scroll the page to the anchor described above

in XHTML or HTML5 use [B]id[/B] attribute instead of [B]name[/B]
×

Success!

Help @KGDeem spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...