Friday 15 June 2012

html - Anchor links inside iframe does nothing -


Is it possible to have a non-scrolling iframe inside a scrolling div, and anchor link inside the work of IFrame Are you right? The anchor link should be taken inside the IFrame inside the IFrame, I do not need them to point to the elements on the parent page.

Here are my JSfields a simple example:

and the code for that:

    

I have no relation with the hypergroup dot link used in my example, it was just one of the first examples, in which I used to sign an anchor with the ID / name syntax link Could get together

If you load JSFiddle and click on the "Go down from the bottom" link inside the ifframe, then it does nothing (tested with Firefox 19.0.2) when the various pages Testing with Firefox never works anytime, in Chrome it sometimes clicks for the first time, but clicks on it, but then if you scroll up and click again then it does not work is. This works most of the time (scrolls) in IE8.

If I give the scrollbar in the iframe (scrolling = "no"), scrolling works at the right time. This is not a practical solution for me, because I have content outside the frame, which I want to scroll with. In my actual code, I set the height of the IFrame to fill my content dynamically, in this way it appears more like content on my page.

Why do I need to do this:

I am making a web-based email client and displaying the HTML body of the email inside an iframe so far At least there are some problems, vs. trying to display inside a cell cell or diva. I want to work for these types of links. I have some control over the content, it comes from my server and I can modify it (but do not want to hack it too much). For example, I already modify all the links to open in a new window (but the link does not start with #, so my problem is not).

I know Gmail does not use IFrame, but my XFINITY (by Comcast Cable) web-based email client, and managed to work on them (but have not figured out yet That's what they're doing)

Look at this post:

If your iframe is a separate domain then You will be unable to use the Javascript solution to solve it, but if so, you can add target = "_parent" attribute to all anchors within the iframe.

  var iframe = document.getElementById ('iframeId'); Var doc = (iframe.contentDocument)? Iframe.contentDocument: iframe.contentWindow.document; Var anchor = doc.getElementsByTagName ('a'); For (var i = 0; i & lt; anchors.length; i ++) anchor [i] .target = '_parent';    

No comments:

Post a Comment