Forum Moderators: open

Message Too Old, No Replies

Open a page in a new frameset to an anchor?

(not inside the current frameset...)

         

LorenAmelang

11:38 pm on Feb 20, 2003 (gmt 0)

10+ Year Member



I'm trying to keep my page titles and bookmarking results matched to the content of the current "text" frame, yet still have one single file appear as the "directory" frame all the time. Each new "text" page is loaded by requesting its matching frameset, with its own title, that replaces the calling frameset, loads the same "directory" frame content as before, and loads the new text page into the "text" frame. It looks great, you always know where you are, and if you save a bookmark you will return to the exact same view.

But I can't find any HTML way to open the new text page to an anchor somewhere down the page - inside a new frameset. I can open the new text page inside the "text" frame (or any other frame) of the _current_ frameset, and still specify an anchor to position at. I can open the page by itself in an entirely new window, at any anchor, either replacing or popping over the calling frameset.

I've found several questions like this on other sites, with lots of answers that end up opening inside the current frameset, or standalone in a new window, but none of them do what I want. Is that because it is just impossible in HTML? (That would explain why nobody seems to bother doing it...)

I'd settle for popping up the new text page to an anchor in its own new non-frame window, IF I could control the size of the window, like I can the frame it is intended to be in. But neither the HTML or JS versions seem to be at all portable. Some browsers always end up with the new window completely hiding my calling frames.

Ideas welcome!

Loren

tedster

1:29 am on Feb 21, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome to the forums, LorenAmelang.

Have you considered using iframes for your content, instead of complete framesets? With iframes you can load a document to a named anchor.

If that doesn't do it for you, you should be able to control both the sized and the position of a pop-up window. The code for sizing and positioning is in our generic javascript thread [webmasterworld.com], messages 4 through 6.

The big deal with positioning is that for cross-browser support you need to include two sets of parameters which actually represent the same thing: screenX, screenY and left, top

LorenAmelang

1:22 am on Feb 23, 2003 (gmt 0)

10+ Year Member



Hi tedster, thanks for the quick response.

I took another look at using iframes, but I think what I want to do runs into the same problem you dealt with in the "Iframes Linking To Another Iframe With Anchor Tags" thread. I can see what you are suggesting, but iframes already don't work in older browsers, and adding JS on top of them probably isn't the way I want to go. My site is targeted at non-techies who may not be up-to-date in the browser area.

So back to popups... Yes, I know they aren't universal, either, but I think they may be a lesser evil. Time and feedback might still change my mind.

I now understand where I got off-track before. The script function must be placed in the HEAD of the top _frameset_ document, not in the content pages that get loaded into the frames! When I put it in the HEAD of the content page, it didn't work, returning "Object expected" (IE) or "Reference to undefined variable" (Opera) errors. My response to that was to try the JS inline, which worked but put up a new page under the popup with nothing but "[object]" (IE) or "[object Object]" (Opera) in it.

One fix for that was '<A href="javascript:void(0);" onclick="window.open(...)">', which works but puts the "javascript:void(0);" message in the tooltip or status bar (like you see everywhere, but I think it is tacky).

The other was '<A href="javascript:window.open(...); return false;">', which properly shows you where it is going to take you, but doesn't work in IE ('return' statement outside of function).

You might want to add a note to your "handy, generic script" thread about the HEAD functions needing to be in the _frameset_ document to work with frames. For us rank beginners, you might want to also include the entire

<SCRIPT language="javascript"><!--
function x(...){...}
//--></SCRIPT>

form at least once, so we don't forget!

Now that the script is in the frameset HEAD, the remaining problem is more trivial. IE (6) measures the window position from the absolute edge of the screen, while Opera (7) measures from the bottom of the text menu bar (even if other toolbars are below there putting the actual display window even lower). I wish there was a way to measure relative to the content window.

And of course without script support those links just don't work. Oh, well, that's why there is a whole alternate text site... I've seen this form several places:

<a href="page.html" onClick="cPop('page.html','window1',www,hhh);return false">Link Text</a>

"Spiders and visitors with JS turned off get a regular link to follow. JS users get the pop-up. The ;return false keeps the original page from changing when a visitor gets the pop-up."

It never pops for me in any browser, always puts up the full HTML window. Is there a secret?

Here's what I ended up with:

<SCRIPT language="javascript"><!--
function jPop(url, windowname, wide, high, hpos, vpos, scroll, size)
{
window.open(url, windowname, 'width=' + wide + ',height=' + high
+ ',left=' + hpos + ',top=' + vpos + ',screenX=' + hpos + ',screenY=' + vpos
+ ',scrollbars=' + scroll + ',resizable,=' + size);
}
//--></SCRIPT>

And:

<a href="javascript:jPop('intro.html#child','child',400,300,200,100,1,1)">Click for popup window</a>

The popup links appear at the chosen anchor point, with their proper window titles, and they can be bookmarked. The site frameset, with the table of contents frame, remains visible under the popup. If someone comes back to the popped page without its frameset, there is a link at the bottom which takes them back to the framed TOC. Actually I like this better than replacing the whole calling window - you can check, say, the definition of a word, without losing your place in the text you were reading.

Thanks again for listening!

Loren