/    Sign up×
Community /Pin to ProfileBookmark

iFrame positioning

For reasons too boring to go into, I have a frameset with 3 horizontal frames. All three are static, but the third contains a large iframe that pulls in a 3 page form from another domain.
At the bottom of each form page, is a submit button and this works just fine, bringing the next page into the iframe as planned.
My problem is that the form is long (it contains some images) and the user has to scroll down the screen to get to the bottom. When the user submits and the next page turns up in the iframe, it still shows the iframe in the frame exactly where the user left it before the iframe page changed, thus meaning that the user is presented with the second and third pages of the form part way down – really helpful.
Does anyone know a way to force it to go to the top of the page each time the iframe page is changed?
Thanks
Nik

to post a comment
JavaScript

11 Comments(s)

Copy linkTweet thisAlerts:
@KorJul 19.2005 — <script type="text/javascript">

onload = function(){location.href=location.href+'#'}

</script>

will keep the page always on top onload.
Copy linkTweet thisAlerts:
@GiraffeBirdauthorJul 19.2005 — Thanks for the quick reply.

Excuse my ignorance (Javascript really isn't my thing - obviously!) but where do I stick this code? I've tried it in the head of the frameset, the second page of the form code (on the other domain) and on the page containing the iframe buit not having much luck so far.

Thanks!
Copy linkTweet thisAlerts:
@KorJul 19.2005 — the code should be placed in the HEAD of the page you want to keep it on top. Should work, if the page is loaded/reload durring the submit process... Or it does not?
Copy linkTweet thisAlerts:
@GiraffeBirdauthorJul 19.2005 — The page within the iframe reloads when the user submits, but the page the iframe is contained within doesn't (I guess) so this page stays where it is, halfway down my form placed within the iframe.
Copy linkTweet thisAlerts:
@GiraffeBirdauthorJul 19.2005 — Actually, it should still work! I've just tried adding a textbox to the top of the second page of the form and putting an onFocus thing on it and that works. I must be doing something wrong with your code - I copied it and pasted it in the head. Was I supposed to use my brain and replace the # with something?
Copy linkTweet thisAlerts:
@KorJul 19.2005 — aha... in this case try insert in the form tag this piece of code

<form onsubmit ="return function(){top.frames['framename'].location.href=top.frames['framename'].location.href+'#'}"........>

where 'framename' is the name of the frame where lays the page u wanna bring to top.
Copy linkTweet thisAlerts:
@GiraffeBirdauthorJul 19.2005 — Good plan, but it won't allow me two onSubmits in the same Form. Can I have a second form that doesn't actually do anything other than submit this info? I can make one but not sure how to get it to submit without the user pushing something.
Copy linkTweet thisAlerts:
@KorJul 19.2005 — 
it won't allow me two onSubmits in the same Form
[/quote]

But it allows use several functions to be triggered on the same onsubmit, so that you may insert the code inside the function (probably a validate) somewhere before the return true
Copy linkTweet thisAlerts:
@KorJul 19.2005 — ...........
Copy linkTweet thisAlerts:
@GiraffeBirdauthorJul 19.2005 — Genius! Thanks Kor.

I don't know quite what I'd done wrong before, but I've now put your original code in the head of the second two pages it works. I must have been doing soemthing really thick before to stop it working.

Thank you so much for your patience and help

Nik.
Copy linkTweet thisAlerts:
@KorJul 19.2005 — u're welcome...
×

Success!

Help @GiraffeBird 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.15,
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,
)...