|
|
|
|
|
|
Re: "document" unresolved for javascript files [message #209072 is a reply to message #209065] |
Mon, 25 February 2008 13:07  |
Eclipse User |
|
|
|
Thanks Bradley! By selecting the project and going into
Properties->JavaScript Libraries -> Global Order/Super Type and changing
the dropdown at the bottom of that page to "Window" I now have my little
example working.
I'll comment though that this isn't at all obvious (apparently <g>). So
there's some usability concern around getting novice developers going
quickly.
Thanks again,
Kevin McGuire
Bradley Childs wrote:
> The super type of a project is the type who's fields / methods are inherited
> by all .js (and .html files if in a web project).
>
> By definition for .js files the super type is (an instance of) the Global()
> object. When JavaScript is running within the context of a browser,
> inheritance is Global()--->Window() and [an instance of]Window() is the
> super type. 'document' is a field in the Window object of type Document().
>
>
>
> -Brad
> "Kevin McGuire" <eclipse@kevin.mcguireclan.net> wrote in message
> news:fpn7ka$tdm$1@build.eclipse.org...
>> Hi Nitin,
>>
>> Thanks for the response. Sorry I don't understand. The super type of
>> whom? I should be able to write:
>>
>> <script type="text/javascript">
>> function doit() {
>> var newString = "hello world";
>> var content = document.getElementById("content");
>> alert(content);
>> content.innerHTML = newString;
>> }
>> </script>
>>
>> Both document and alert() get compile errors (yet this is normal legal
>> javascript AFAIK and runs just fine in Firefox).
>>
>> Btw, the "Document" choice is quite odd. Its a browser class alright that
>> you'll find in a Javascript book, but I don't think you typically send
>> static methods to it and code completion offers instance method choices on
>> the static.
>>
>> I've logged:
>> https://bugs.eclipse.org/bugs/show_bug.cgi?id=219886 :: "document" shows
>> as error even with ECMA 3 lib added
>> https://bugs.eclipse.org/bugs/show_bug.cgi?id=219880 :: Code completion
>> offers illegal choices
>>
>> The first one might be a bug or might be a UI issue (not guiding the user
>> to the right configation), the second is definitely fishy.
>>
>> Its a very nice javascript editor otherwise! :)
>>
>> Cheers,
>> Kevin McGuire
>>
>>
>> Nitin Dahyabhai wrote:
>>> Kevin McGuire wrote:
>>>> Final stupid question: shouldn't "document" with a lower case 'd' be
>>>> available in the ECMA bindings?
>>> I think "document" is a variable only available if you set the super type
>>> to a web Browser object. I don't know what "Document" refers to, but I'm
>>> guessing it is a W3C DOM object, but then I'm not an expert in
>>> Javascript. For all I know they're unrelated.
>>>
>>> ---
>>> Nitin Dahyabhai
>>> Eclipse WTP Source Editing
>>> IBM Rational
>
>
|
|
|
Powered by
FUDForum. Page generated in 0.08433 seconds