468,170 Members | 1,967 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,170 developers. It's quick & easy.

FireFox and Local Links within Generated Content exhibits problems

The scenario: 1) Generate a popup window via script. 2) Populate it (again
via script) with content that features local (hash) links.

In IE 6.x this works - the links work as they should, moving the document to
that document position. However in FireFox 1.x the links load the main page
(the opener) in to the popup.

Both browsers populate the location.href of the popup with the main page's
href... but this only adversly affects FireFox (which seems to, in this
scenario, reload the whole page on a local link). I tried manually
populating the location.href but no joy.

I've appended an example which demonstrates the problem. I've tried to
shave it down as much as I could. Just save it to an HTML page and load it
up in FireFox. Click the button then scroll down and click the link...
instead of returning to the top of the page I get the opener page's HTML
populated into the popup.

Any thoughts on how to address this? I've Googled, but it may just be that
I've been unable to hit on the right terms to uncover the answer.

Thanks in advance for any direction,

Jim Davis
<html>
<head>
<title>Test Page</title>
<script type="text/JavaScript">
function CreateTestPopup() {
// Create Window
TestWindow =
window.open("","TestWindow","scrollbars=yes,resiza ble=yes,width=500,height=400");
var TW = TestWindow.document;
// Write the HTML
TW.write( "<html><head>",
" <title>Test Window</title>",
"</head><body>",
"<a name='PageTop'>Page Top</a>",
"<br><br><br><br><br><br><br><br><br><br><br>" ,
"<a href='#PageTop'>Go To Page Top</a>",
"</body></html>");
};
</script>
</head>
<body>
<p>This is just a test page.</p>
<p><input type="button" onclick="CreateTestPopup();" value="Launch
Popup"></p>
</body>
</html>
Sep 1 '05 #1
3 1860
Jim Davis wrote:
The scenario: 1) Generate a popup window via script. 2) Populate it (again
via script) with content that features local (hash) links.

In IE 6.x this works - the links work as they should, moving the document to
that document position. However in FireFox 1.x the links load the main page
(the opener) in to the popup.

Both browsers populate the location.href of the popup with the main page's
href... but this only adversly affects FireFox (which seems to, in this
scenario, reload the whole page on a local link). I tried manually
populating the location.href but no joy.
The problem is that because you don't supply a URL, the popup uses the
URL of its parent. Clicking on the link links to the parent page - see
below.

[...]
<html>
<head>
<title>Test Page</title>
<script type="text/JavaScript">
function CreateTestPopup() {
// Create Window
TestWindow =
window.open("","TestWindow","scrollbars=yes,resiza ble=yes,width=500,height=400");
var TW = TestWindow.document;
// Write the HTML
TW.write( "<html><head>",
" <title>Test Window</title>",
"</head><body>",
"<a name='PageTop'>Page Top</a>",
"<br><div onclick='alert(window.location.href)'>",
"Show href</div>",
"<br><br><br><br><br><br><br><br><br><br><br>" ,
"<a href='#PageTop'>Go To Page Top</a>",
"</body></html>");
};
</script>
</head>
<body>
<p>This is just a test page.</p>
<p><input type="button" onclick="CreateTestPopup();" value="Launch
Popup"></p>
</body>
</html>


Click on the text 'Show href' in the popup to see what I mean.

You could try linking to a real document and replace the content of the
HTML element. That will allow you to set a doctype etc and have a valid
document to boot.

--
Rob
Sep 1 '05 #2
"RobG" <rg***@iinet.net.au> wrote in message
news:LA*****************@news.optus.net.au...
Jim Davis wrote: <snip>
The problem is that because you don't supply a URL, the popup uses the URL
of its parent. Clicking on the link links to the parent page - see below.
Yes... I agree that this is probably the cause... but how to get around it?

The behavior still strikes me as damn peculiar. I mean if FireFox sets the
href as the main page, fine (so does IE) - but internally it must lose this
someplace because it reloads the entire page when you go to an internal
link. On any other page with internal links it doesn't seem to reload the
page - it just scrolls to the target.

For it to do what it's doing it has to be comparing what it's displaying as
the href with something else, finding them different and reloading the page
using the "new" href.
Click on the text 'Show href' in the popup to see what I mean.
Oh - I already knew that: I actually said so in my original message. ;^)
You could try linking to a real document and replace the content of the
HTML element. That will allow you to set a doctype etc and have a valid
document to boot.


I'm sure that would solve it.

Unfortunately in this case I can't link a "real" document - this code is
part of a public debugging library: it may be used with Internet Access,
without Internet access, locally via a server, etc. The libraries may be
called from an external file or embedded in the main page.

As for the doctype - there's no reason I can't set it here: I just stripped
the code to the bone for the example (the code displays the same behavior
doctype or no).

Thanks for the thoughts,

Jim Davis
Sep 1 '05 #3
*** Jim Davis wrote/escribió (Wed, 31 Aug 2005 22:11:00 -0400):
The scenario: 1) Generate a popup window via script. 2) Populate it (again
via script) with content that features local (hash) links.

In IE 6.x this works - the links work as they should, moving the document to
that document position. However in FireFox 1.x the links load the main page
(the opener) in to the popup.


If you add document.write(this.location.href) to the child window you'll
see that its URL remains the same as its parent's (that's the same in both
browsers). So IE's behaviour is not really consistent.

I suggest you use the focus() method to browse child page.
--
-- Álvaro G. Vicario - Burgos, Spain
-- http://bits.demogracia.com - Mi sitio sobre programación web
-- Don't e-mail me your questions, post them to the group
--
Sep 1 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

10 posts views Thread by Vincent Poinot | last post: by
4 posts views Thread by Stuart Perryman | last post: by
1 post views Thread by Andy Stevenson | last post: by
6 posts views Thread by Mark Olbert | last post: by
13 posts views Thread by Giggle Girl | last post: by
14 posts views Thread by arteccentrix | last post: by
2 posts views Thread by Steve D. | last post: by
reply views Thread by kamranasdasdas | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.