<a href="javascript:window.frames.foo.document.location='http://bar'> does not work properly (iframe)




DOM: Core & HTML
16 years ago
16 years ago


(Reporter: Aaron Kaluszka, Assigned: jst)


Windows XP

Firefox Tracking Flags

(Not tracked)



(1 attachment)



16 years ago
A link in the form of
<a href="javascript:window.frames.foo.document.location='http://bar';">
does not work like
<a href="#" onclick="window.frames.foo.document.location='http://bar';">
Instead of loading the target page in an iframe, the entire page is refreshed
with the text displaying the URL or about:blank or wysiwyg://... but the favicon
is loaded properly
For reference, IE has similar behavior, but the text is always the URL.

Comment 1

16 years ago
Created attachment 86058 [details]

Oddly enough, in IE, if you click on the good link before the bad, an access
denied error is generated.  In Mozilla, the last location is displayed as text.


16 years ago
Keywords: mozilla1.1

Comment 2

16 years ago
2002060208-trunk btw
Try returning "false" at the end of the javascript: url.  Otherwise the return 
value (in this case most likely the URL) should replace the contents of the 
previous page (so one can do things like "javascript:<body>text</body>"

Comment 4

16 years ago
Then Mozilla generates the error, "invalid return" and does nothing.  In
addition, note that the favicon loads in the original testcase.  Why would it
overwrite the page with the value in the first place?  I am setting the
variable, not document.write-ing it.  javascript:<body>text</body> just gives a
syntax error, btw.

Comment 5

16 years ago
javascript:"<body>text</body>"; (note that you need the quotes) _should_ replace
the current document with the result of parsing the value of the JS expression
in the javascript: URL, this always happens with javascript: URL's unless the
value of the expression in the javascript: URL is |undefined|. This has nothing
to do with document.write(). So what you want to do is to make the JS expression
in the javascript: URL evaluate to undefined, to do this add |void(0);| at the
end of your javascript: URL. This is not a bug, mozilla works exactly as
designed here, what's happening is that you're setting the location of a frame
to a string, and that results in the expression in the javascript: URL to
evaluate to whatever the value of the location object is after you've set it
(most likely the value you set it to, or the previous value, depending on timing
n' what not). And as I explained above, since the value of the expression in the
javascript: URL is not undefined mozilla will pares that value as HTML into the
window where the link was. This will most likely result in the whole document
being replaced with that string, and that means that the frame on which you set
the location will be unloaded since the document that contained it is replaced
with a new document. IE works just like mozilla does wrt this, and AFAIK so does
every other browser.

Last Resolved: 16 years ago
Resolution: --- → INVALID

Comment 6

16 years ago
Not quite.  Notice that the favicon for the target location is still loaded. 
Though the process for reproducing this might not be directly relevant to the
problem, there is still something wrong.
Resolution: INVALID → ---

Comment 7

16 years ago
Please file a separate bug on that problem.
Last Resolved: 16 years ago16 years ago
Resolution: --- → INVALID

Comment 8

16 years ago
Umm it was part of the same bug, mentioned in the initial report, but whatever...
->bug 148821
You need to log in before you can comment on or make changes to this bug.