Open
Bug 355321
Opened 19 years ago
Updated 3 years ago
'<iframe src="javascript: foo(11)"></iframe>' results in "foo is not defined" (even though it is defined above the iframe)
Categories
(Core :: DOM: Core & HTML, defect)
Tracking
()
UNCONFIRMED
People
(Reporter: mozilla, Unassigned)
Details
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.0.7) Gecko/20060911 SUSE/1.5.0.7-1.1 Firefox/1.5.0.7
Build Identifier: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.0.7) Gecko/20060911 SUSE/1.5.0.7-1.1 Firefox/1.5.0.7
[Sorry for the "General" categorization-- couldn't find any component for JavaScript, frames, or HTML rendering.]
If you have an <iframe> tag whose "src" attribute is set to a "javascript:" pseudo-URL, then when that URL is executing, it cannot find functions that should be accessible, and thus JS execution is halted. Here's a small HTML file to reproduce the problem:
=========================================
<html>
<body>
<script>
function foo(s) {
alert(s) ;
return s ;
}
</script>
<iframe src="javascript: foo(11)"></iframe>
</body>
</html>
=========================================
If you load this page, you will see in the JavaScript console that "foo is not defined", even though it was just defined. This happens whether foo() is defined in the head or the body of the document.
It does not happen with all tags; e.g. "<img src=...>" works fine. <iframe> is the only tag I know of where it fails.
The <iframe src="javascript:..."> construct is used on the new mail.yahoo.com , so it won't be a rare occurrence.
Reproducible: Always
Steps to Reproduce:
1. Create test HTML file as described in the "Details:" section above.
2. Load HTML file into Mozilla.
3. Look at the JavaScript console to see the error.
Actual Results:
JavaScript console shows "Error: foo is not defined". Execution of further JavaScript halts.
Expected Results:
The function foo() is in scope (right?) and should be found when executing the javascript: URL.
| Reporter | ||
Comment 1•19 years ago
|
||
Whoops, change one thing in the description-- further JavaScript execution does not actually halt upon this error. Sorry, thought I tested that.
Updated•19 years ago
|
Summary: If you have e.g. '<iframe src="javascript: foo(11)"></iframe>', the function that's called inside the javascript: URL (in this case, foo()) is not found, even if it's been defined earlier or far earlier than the <iframe> tag; JavaScript execution halts. → '<iframe src="javascript: foo(11)"></iframe>' results in "foo is not defined" (even though it is defined above the iframe)
Updated•19 years ago
|
Assignee: nobody → general
Component: General → DOM
Product: Firefox → Core
QA Contact: general → ian
Version: unspecified → 1.8 Branch
Updated•16 years ago
|
Assignee: general → nobody
QA Contact: ian → general
Comment 2•14 years ago
|
||
The function is not in the scope.
performing the same test for
<iframe src="this.parent.foo(11)"></iframe>
we get the expected result.
now, this doesn't seem to be a bug to me.
the reason being, since we actually can have javascript within the iframe, allowing iframe access to all the parent's variables and methods with out mentioning 'this.parent' could lead to conflicts and since images can't have javascript, it is ok.
| Assignee | ||
Updated•6 years ago
|
Component: DOM → DOM: Core & HTML
Updated•3 years ago
|
Severity: normal → S3
You need to log in
before you can comment on or make changes to this bug.
Description
•