/    Sign up×
Community /Pin to ProfileBookmark

iframe onclick top of page code????

Hi,

I am building a website currently that has:

A main page which has an iframe in it (the parent page). There is a menu on this page where the links are targeted to open in the iframe. The iframe has scrolling disabled and the iframe adjusts to fit the content of the child page.

My question is… is there a way to make the page scroll to the top (of the parent page) when a link is clicked instead of the parent page remaining scrolled half way down where the link originally was clicked on the previous child page.

I was thinking maybe something along the lines of “onClick”. I have tried a few codes I’ve found online but none seem to work. I don’t want this code to interfere with the code I currently have that resizes the iframe to fit the child page contents.

I’m pretty new to all this so please be patient. ?

Attachments:

iframe1 = one of the pages of my site. a list of linked images in the iframe. yellow text just letting u know where everything is.
iframe2 = this is what happens when the link is clicked. notice the page is scrolled down a bit.
iframe3 = this is how i want the page to load when a link is clicked. scrolled up to the top.

[upl-file uuid=1e25b028-7855-4169-9065-1d63392dda12 size=35kB]iframe1.JPG[/upl-file]

[upl-file uuid=d6b0013d-2cb5-483d-acc0-b87efd32944e size=38kB]iframe2.JPG[/upl-file]

[upl-file uuid=3f4af195-a935-4a2d-9e5f-e75306d2d278 size=42kB]iframe3.JPG[/upl-file]

to post a comment
HTML

1 Comments(s)

Copy linkTweet thisAlerts:
@FangOct 28.2007 — Add this to all the iframe documents:window.onload=function() {top.scrollTo(0,0);};
×

Success!

Help @TwiggySkold5 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.16,
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,
)...