SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Zealot TCJeter's Avatar
    Join Date
    Jun 2002
    Location
    Anchorage, AK
    Posts
    187
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Need some code clean-up...

    On this page of a site I maintain, I have a list of links that open pop-up windows with short descriptions. The window is called using the onClick=MM_openBrWindow() behavior and the link is highlighted using an anchor(#).

    When it opens the pop-up, the main page would automatically jump to the top because the "#" is basically a link to the same page (i.e. -refresh). I tried to correct this by linking to the named anchors, but it will still move and put the anchor at the top of the page.

    Is there a way to make the page return to its original position? Or a way to highlight the link (and make the cursor show that it is a link) without using the anchor?
    Am I just making this way too compicated??

    Thanks for the input,
    TC

  2. #2
    gingham dress, army boots... silver trophy redux's Avatar
    Join Date
    Apr 2002
    Location
    Salford / Manchester / UK
    Posts
    4,838
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    tc, yes there is a way, AND using this method (which i attempt to do most of the time) you also - as i byproduct - make those links accessible to text browsers and browsers with javascript disabled...now how's that for nice ?
    here's the deal. let's take one example link
    Code:
    <a href="#1306a" onClick="MM_openBrWindow('/pop_ups/1306a.htm','Philips26','width=500,height=350')">Philip's 
                26 Glacier Cruise with Rail</a><a name="1306a"></a>
    right, i see you've tried it using a local anchor. nice, but messy - and still inaccessible. change all your links to follow this format
    Code:
    <a href="/pop_ups/1306a.htm" onClick="MM_openBrWindow('/pop_ups/1306a.htm','Philips26','width=500,height=350'); return false;" target="_blank">Philip's 
                26 Glacier Cruise with Rail</a>
    now, what have i done here ? well, the href now points to the same file as your openBrWindow call, and the link has a target="_blank". the nifty part is the added "return false" at the end of the onClick behaviour. this is what happens:

    - javascript enabled browsers execute the openBrWindow. the return false tells the browser NOT to process the normal link href...it basically executes the javascript and then does nothing (i.e. it doesn't jump, so you don't need to "fake it" with an anchor and #1306a, for instance)

    - non javascript browsers ignore the onClick behaviour and process the link as normal. the target="_blank" forces visual browsers to open a new window (lynx and other text browsers will just ignore this target as well, and open that document in the same view).

    result ? the code is a little bit cleaner (no myriad of local anchors to be generated), javascript browsers don't need to "bounce around" your page every time you click on a link (as the javascript takes care of everything), and your site is accessible for visually impaired people using text browsers and for those who have javascript disabled.

    re·dux (adj.): brought back; returned. used postpositively
    [latin : re-, re- + dux, leader; see duke.]
    WaSP Accessibility Task Force Member
    splintered.co.uk | photographia.co.uk | redux.deviantart.com

  3. #3
    gingham dress, army boots... silver trophy redux's Avatar
    Join Date
    Apr 2002
    Location
    Salford / Manchester / UK
    Posts
    4,838
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    swimm...he's already using javascript, so your reply seems odd to me
    anyway, not to blow my own trumpet, but the method i suggested above has a lot of advantages in terms of accessibility (sorry if i go on about accessibility all the time, but it IS one of my main concerns at the moment working on a big educational site )
    re·dux (adj.): brought back; returned. used postpositively
    [latin : re-, re- + dux, leader; see duke.]
    WaSP Accessibility Task Force Member
    splintered.co.uk | photographia.co.uk | redux.deviantart.com

  4. #4
    SitePoint Wizard Bill Posters's Avatar
    Join Date
    Dec 2001
    Location
    UK
    Posts
    1,523
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I take it Swimm goofed and bolted

    Awww
    New Plastic Arts: Visual Communication | DesignateOnline

    Mate went to NY and all he got me was this lousy signature

  5. #5
    Former Staff Member silver trophy Adam P.'s Avatar
    Join Date
    Apr 2001
    Location
    San Francisco
    Posts
    3,288
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm caught!
    SPF Mentor/Advisor 2001-2003
    SPF Designer of the Year 2002
    SPF Graphic Designer of the Year 2003
    AdamPolselli.com

  6. #6
    SitePoint Zealot TCJeter's Avatar
    Join Date
    Jun 2002
    Location
    Anchorage, AK
    Posts
    187
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Wink Thanks......

    Redux,
    Thanks for that tid-bit of "accessible" information. That's exactly the way I wanted the window to function.

    Appreciatively,
    -TC


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •