IFram onload

Posted on 2009-02-17
Last Modified: 2012-05-06

i need to set scrollTo(0,0) each time iframe is loaded. i don't want to use html iframe onload since our cms deleted it. is there any alternative to do that ?
Question by:Sh_Rashed
    LVL 51

    Expert Comment

    why not simply define an anchor and add it to the iframe's src URL?

    Author Comment

    umm how would i do this ?
    LVL 51

    Accepted Solution

    in the page loaded with your iframe you have (somewhere right after the body tag):

    <.body><.a name="top">

    then you use your iframe like:

    <.iframe src="path/to/page.html#top" />

    (please remove the . dot)

    Standard since 1993 ;-)

    Author Comment

    i have to put this code in every page that will be loaded in the iframe?
    coz when i click a link in th iframe and open it in the iframe  the browser scroll doesn't move
    LVL 51

    Expert Comment

    > .. when i click a link in th iframe
    are you talking about A tags in the loaded page, then it's the responsibility of that link
    but if it doesn't have a (anchor)fragment it loads with visibility from top anyway (unless some more or less sophisticated active scripting in there does something different)

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    Accessibility and Usability are two concepts that seem to be closely related.  But, too many people seem to have a distorted perception of them. During last five years, those two words have come to the day-to-day work of almost every web develope…
    Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
    This tutorial walks through the best practices in adding a local business to Google Maps including how to properly search for duplicates, marker placement, and inputing business details. Login to your Google Account, then search for "Google Mapmaker…
    Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now