Closed
Bug 255208
Opened 21 years ago
Closed 21 years ago
Can get but not set DOM properties cross-frames (eg in another frame of a frameset)
Categories
(Core :: DOM: Core & HTML, defect)
Tracking
()
RESOLVED
INVALID
People
(Reporter: kimj90, Unassigned)
Details
Attachments
(3 files)
User-Agent: Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.7) Gecko/20040514
Build Identifier: Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.7) Gecko/20040514
Mozilla can not set DOM properties cross-frames.
(it can read but not write properties).
Example, using 3 attached files:
main.html, creates a frameset
textframe.html, chooses among 3 pictures to display
pictframe.html, displays selected picture.
textframe.html does the primary work.
Two code branches tested: document.all and document.getElementById
Under MSIE 5.5, both branches were tested and worked fine.
Under Mozilla 1.7, only the document.getElementById branch
is tested. The alert box shows it can read the property value
parent.PictFrame.document.getElementById("PictDisplay").src
(returns the correct initial photo filename src)
but can not set that property value. The new value is ignored.
The "after" trace is the same as the "before" trace.
That Mozilla can display the initial photo src value means
that the DOM access path is correct.
Javascript Console does not list any errors.
Does have a (Warning: reference to undefined property document.all)
which is proper as it then skips that code branch.
Requested change:
Mozilla should be able to set properties cross-frames.
Related bugs:
bug 210153 might be related, but no test case was ever posted.
bug 213066 might be related, it just says the frames are not
shown, but that could be for many reasons. Impossible to
say now because the test website was not reachable.
Reproducible: Always
Steps to Reproduce:
MAIN.HTML
---------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<frameset rows="40%,*">
<frame id="TextFrame" name="TextFrame" src="TextFrame.html">
<frame id="PictFrame" name="PictFrame" src="PictFrame.html">
<noframes>
This browser does not support frames.
Please upgrade to a modern browser.
</noframes>
</frameset>
</html>
PICTFRAME.HTML
--------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<title>Picture Display</title>
</head>
<body>
This is the picture frame
<br>
<img id="PictDisplay" name="PictDisplay" src="first_logo.gif" />
</body>
</html>
TEXTFRAME.HTML
--------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<title>Text Menu Option Frame</title>
<SCRIPT language="javascript" type="text/javascript">
<!--
function selectphoto (pictfile) {
var basepath = "subdir/";
var fullname = escape (basepath + pictfile);
if (document.all) {
// MSIE works ...
alert ("document.all branch\nBEFORE change\n" +
"window.top.frames['PictFrame'].document.images['PictDisplay'].src=\n" +
window.top.frames['PictFrame'].document.images['PictDisplay'].src);
// set the value
window.top.frames['PictFrame'].document.images['PictDisplay'].src=fullname;
alert ("AFTER change\n" +
"window.top.frames['PictFrame'].document.images['PictDisplay'].src=\n" +
window.top.frames['PictFrame'].document.images['PictDisplay'].src);
return true;
} else {
if (document.getElementById) {
// MSIE works ...
alert ("getElementById branch\nBEFORE change\n" +
"parent.PictFrame.document.getElementById('PictDisplay').src=\n" +
parent.PictFrame.document.getElementById('PictDisplay').src);
// set the value
parent.PictFrame.document.getElementById("PictDisplay").src = fullname;
alert ("AFTER change\n" +
"parent.PictFrame.document.getElementById('PictDisplay').src=\n" +
parent.PictFrame.document.getElementById('PictDisplay').src);
return true;
} else {
alert ("(selectphoto) this code is not compatible with your browser");
return false;
};
};
};
// -->
</script>
</head>
<body>
This is the text frame<br>
// invoke the change of photos
<img src="button1.gif" onClick="selectphoto('logo1.jpg');" /><br>
<img src="button2.gif" onClick="selectphoto('logo2.jpg');" /><br>
<img src="button3.gif" onClick="selectphoto('logo3.jpg');" /><br>
after the buttons
</body>
</html>
Actual Results:
both the 1st and 2nd Alert boxes report
src="first_logo.gif"
Expected Results:
Property in PictFrame should be changed,
as demonstrated by the 2nd Alert box reporting
src="logo1.jpg" or whatever file was associated with that button.
Comment 1•21 years ago
|
||
Comment 2•21 years ago
|
||
Comment 3•21 years ago
|
||
Comment 4•21 years ago
|
||
The testcase I attached (just the HTML you pasted, basically) worksforme with
both a current trunk build and a 1.7 build (both on Linux).
Does this testcase fail for you? If not, could you please attach a testcase
that does?
> Does this testcase fail for you?
Yes. Exactly as loaded, it fails under Mozilla 1.7 and Win98 SE.
Ok -- Click on "FrameSet", puts up the two frames
Ok -- Click any picture button (graphic not loaded), starts selectphoto function
Ok -- First alert box, takes the branch document.getElementById
Ok -- BEFORE info, src=first_logo.gif
FAIL -- Second alert box, with AFTER info, src is unchanged, src=first_logo.gif
src should have been set to logo1.gif, logo2.gif, etc.
Additional confirmation:
when running the original test case with graphics files first_logo.gif,
logo1.gif, etc, under Mozilla the picture displayed onscreen is
unchanged (first_logo.gif).
This indicates the failure is not merely the reporting of the src
property. It appears to be the setting of the property.
---------------------
Minor change during creation of attachments.
This does NOT affect test results.
The original textframe.html became testframe.html (test rather than text)
Does not matter because the file attachment was referenced by an attachment
number, not the filename.
Thank you for your efforts.
Comment 6•21 years ago
|
||
Do you have setting if Image.src disabled in your preferences, perchance? The
"Advanced > Scripts & Plug-ins > Change images" option?
Hi Boris:
Bingo! Good diagnosis.
Preferences: Advanced / Scripts / "Change Images" was unchecked.
Checking that box & rerunning the test cases, it works.
Thank you.
Have a feeling this is still a bug, somewhere :-)
a) Javascript Console should have reported a Warning or Caution.
Something like
"Attempt to change Image SRC. Blocked by Preference Option 'Change Image'"
b) The original test case (not sent) enclosed the javascript line
that set the value in a try / catch block. If you try to change a value
and it is not changed, for whatever reason, shouldn't that trigger
an exception?
Should have received "catch" error message something like
"Attempt to change Image SRC. Blocked by Preference Option 'Change Image'"
Perhaps this bug 255208 should be changed / resubmitted as a
bug / enhancement to Javascript Console and to Javascript language?
Thanks!
Comment 8•21 years ago
|
||
No, that preference exists precisely to silently, and without exceptions, block
changes to Image.src. There are other ways that will throw exceptions, but this
preference is designed to not stop script execution. So everything is working
as it should.
Status: UNCONFIRMED → RESOLVED
Closed: 21 years ago
Resolution: --- → INVALID
Updated•7 years ago
|
Component: DOM → DOM: Core & HTML
You need to log in
before you can comment on or make changes to this bug.
Description
•