Solved

Anchor Tags and IE8

Posted on 2012-03-12
6
616 Views
Last Modified: 2012-04-02
I have a page that has anchor tags.   A user clicks on a link that pops up a new window to add notes to the option for a presenation.   Once they are done adding notes, the pop-up window has a javascript to refresh the parent page to show that notes have been added to that slide.    The list of options on the parent page is fairly long so the desire is to have the refresh return to the anchor/slide that was just modified so that the user doesn't have to scroll back down.    This works just fine in Firefox and Chrome but doesn't in IE.    It refreshes the page but doesn't go to the anchor.   I have seen some comments that IE just gives up right away if the anchor is written yet so I imagine that is my problem.    Does anyone have a solution to this?
0
Comment
Question by:digitalwise
  • 3
  • 3
6 Comments
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 37713647
Showing the script you have issues with would be very useful
0
 

Author Comment

by:digitalwise
ID: 37714413
This is all I am using to refresh.

 <SCRIPT Language="JavaScript">
opener.location.reload();
self.close();
</SCRIPT>

Open in new window

0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 37714441
So you need to send the anchor to the popup so it can do

opener.location="whateverurl.com/page.html#anchor"

instead OR save the anchor in a cookie and do

window.onload=function() {
  var anc = getCookie('currentAnchor');
  if (anc && document.getElementById(anc)) {
    document.getElementById(anc).scrollIntoView()
  }
}

I am using ID instead of name="#somename" here. All modern browsers will allow ID instead
0
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 

Author Comment

by:digitalwise
ID: 37714625
We are using ID as well.   However it still isn't working.  I tried both of your solutions which work great.   But IE just doesn't appear to care.   It appears that IE just doesn't wait for the page to load all of the way and it stops looking for the id when it isn't readily available.   Firefox and Chrome don't have any issues.
0
 
LVL 75

Accepted Solution

by:
Michel Plungjan earned 500 total points
ID: 37714753
This should work in IE for sure.

If not, you may have some other issues like not-unique IDs (which IE normally has less of a problem with than Chrome and Fx)

Did you try the onload?

window.onload=function() {
  var anc = getCookie('currentAnchor');
  if (anc && document.getElementById(anc)) {
    document.getElementById(anc).scrollIntoView()
  }
}

Have a look at this article

http://www.zachleat.com/web/domcontentloaded-inconsistencies/
0
 

Author Comment

by:digitalwise
ID: 37725191
This works on the initial click to open the new window but still not on the reload from the page closing...
0

Featured Post

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses four methods for overlaying images in a container on a web page
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

803 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