Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > FireFox and Local Links within Generated Content exhibits problems

Reply
Thread Tools

FireFox and Local Links within Generated Content exhibits problems

 
 
Jim Davis
Guest
Posts: n/a
 
      09-01-2005
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>


 
Reply With Quote
 
 
 
 
RobG
Guest
Posts: n/a
 
      09-01-2005
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
 
Reply With Quote
 
 
 
 
Jim Davis
Guest
Posts: n/a
 
      09-01-2005
"RobG" <(E-Mail Removed)> wrote in message
news:LAuRe.343$(E-Mail Removed)...
> 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


 
Reply With Quote
 
Alvaro G Vicario
Guest
Posts: n/a
 
      09-01-2005
*** 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
--
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Why do some judges hand exhibits back after a trial? Rocky Computer Support 10 04-25-2010 11:43 AM
ASPNET 2.0 Application exhibits strange behavior. Method calls return "False" until we recycle application pool. Dan D. ASP .Net 0 09-12-2006 02:33 PM
Free VIP Exhibits Pass for NAB 2006 jsolis@studentfilmmakers.com DVD Video 0 01-25-2006 11:07 PM
Toshiba Exhibits HD DVD Player At CEATEC JAPAN 2005. Allan DVD Video 0 10-04-2005 03:33 AM
VHDL-AMS ,This circuit exhibits singularity Steffen Netz VHDL 0 05-03-2004 11:45 AM



Advertisments