Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Opera doesn't like Javascript object, but IE, Firefox, Safari do

Reply
Thread Tools

Opera doesn't like Javascript object, but IE, Firefox, Safari do

 
 
Tim Slattery
Guest
Posts: n/a
 
      01-22-2008
I've used a script provided by Stickman (http://www.the-stickman.com),
which allows a variable number of files to be uploaded from an HTML
page. In a nutshell, when a file is selected, it hides that <input
type="file"...> element, puts the name of the file selected in text on
the page, and creates a new <input...> element. A bit klunky, but it
works.

I've now tested this on IE6, IE7, Firefox, Safari (3.0 for Windows, I
haven't got the Mac version to go yet), and they have no problem with
it. But Opera does.

I include an external javascript file ("mutifile.js") in the head
section of my HTML page. The first thing in this script is

function MultiSelector( list_target, max ){


which defines the MultiSelector object. Way down toward the bottom of
the page is a short javascript block which invokes this object:

<script type="text/javascript">
<!-- Create an instance of the multiSelector class, pass it
the output target and the max number of files -->
var multi_selector = new
MultiSelector(document.getElementById('files_list' ), 0);
<!-- Pass in the file element -->
multi_selector.addElement(document.getElementById( 'fname'));
</script>

Opera gives this message:

Reference to undefined variable: MultiSelector

Why doesn't Opera know what this object is?

--
Tim Slattery
http://www.velocityreviews.com/forums/(E-Mail Removed)
http://members.cox.net/slatteryt
 
Reply With Quote
 
 
 
 
Martin Honnen
Guest
Posts: n/a
 
      01-22-2008
Tim Slattery wrote:

> I include an external javascript file ("mutifile.js") in the head
> section of my HTML page. The first thing in this script is
>
> function MultiSelector( list_target, max ){


Does the Opera error console display any errors caused from processing
that file?

> which defines the MultiSelector object. Way down toward the bottom of
> the page is a short javascript block which invokes this object:
>
> <script type="text/javascript">
> <!-- Create an instance of the multiSelector class, pass it
> the output target and the max number of files -->


Note that JavaScript comments are done with
//comment
or
/*
comment
*/
but not with <!-- comment -->

> var multi_selector = new
> MultiSelector(document.getElementById('files_list' ), 0);
> <!-- Pass in the file element -->
> multi_selector.addElement(document.getElementById( 'fname'));
> </script>
>
> Opera gives this message:
>
> Reference to undefined variable: MultiSelector
>
> Why doesn't Opera know what this object is?


Probably because it found an error processing that file.
Post a URL and we can tell more.


--

Martin Honnen
http://JavaScript.FAQTs.com/
 
Reply With Quote
 
 
 
 
Tim Slattery
Guest
Posts: n/a
 
      01-23-2008
Martin Honnen <(E-Mail Removed)> wrote:

>Tim Slattery wrote:
>
>> I include an external javascript file ("mutifile.js") in the head
>> section of my HTML page. The first thing in this script is
>>
>> function MultiSelector( list_target, max ){

>
>Does the Opera error console display any errors caused from processing
>that file?


Only what I posted here: "Reference to undefined variable:
MultiSelector". That's the only thing on the error console.
>
>> which defines the MultiSelector object. Way down toward the bottom of
>> the page is a short javascript block which invokes this object:
>>
>> <script type="text/javascript">
>> <!-- Create an instance of the multiSelector class, pass it
>> the output target and the max number of files -->

>
>Note that JavaScript comments are done with
> //comment
>or
> /*
> comment
> */
>but not with <!-- comment -->
>
>> var multi_selector = new
>> MultiSelector(document.getElementById('files_list' ), 0);
>> <!-- Pass in the file element -->
>> multi_selector.addElement(document.getElementById( 'fname'));
>> </script>
>>
>> Opera gives this message:
>>
>> Reference to undefined variable: MultiSelector
>>
>> Why doesn't Opera know what this object is?

>
>Probably because it found an error processing that file.
>Post a URL and we can tell more.


Unfortunately, its a restricted system.

--
Tim Slattery
(E-Mail Removed)
http://members.cox.net/slatteryt
 
Reply With Quote
 
VK
Guest
Posts: n/a
 
      01-23-2008
On Jan 22, 8:34 pm, Tim Slattery <(E-Mail Removed)> wrote:
> I've used a script provided by Stickman (http://www.the-stickman.com),
> which allows a variable number of files to be uploaded from an HTML
> page. In a nutshell, when a file is selected, it hides that <input
> type="file"...> element, puts the name of the file selected in text on
> the page, and creates a new <input...> element. A bit klunky, but it
> works.
>
> I've now tested this on IE6, IE7, Firefox, Safari (3.0 for Windows, I
> haven't got the Mac version to go yet), and they have no problem with
> it. But Opera does.
>
> I include an external javascript file ("mutifile.js") in the head
> section of my HTML page. The first thing in this script is
>
> function MultiSelector( list_target, max ){
>
> which defines the MultiSelector object. Way down toward the bottom of
> the page is a short javascript block which invokes this object:
>
> <script type="text/javascript">
> <!-- Create an instance of the multiSelector class, pass it
> the output target and the max number of files -->
> var multi_selector = new
> MultiSelector(document.getElementById('files_list' ), 0);
> <!-- Pass in the file element -->
> multi_selector.addElement(document.getElementById( 'fname'));
> </script>
>
> Opera gives this message:
>
> Reference to undefined variable: MultiSelector
>
> Why doesn't Opera know what this object is?


In the head script, you are not using defer flag? Like
<script src="script.js" defer></script>
If you do then remove it and see if any difference.

Other option is with DOM methods - like getElementById - used before
document load event. Theoretically the engine should send to hell any
such attempts, practically the majority of modern browsers are still
trying to do something useful but in different ways and with different
reliability. Maybe Opera chocks on it but fails to report the error
properly.

Both options failed, the exact page content would be needed to help.
 
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
Comparisons of IE, Opera and Firefox on DOM (Javascript/CSS) support(Opera wins) Bob HTML 24 05-21-2006 05:31 PM
Why is Safari not inserting a new row/field in the same order like IE, Mozilla and Opera Stefan Mueller Javascript 7 12-18-2005 10:53 AM
Like a java applet, but using .net and made for IE, Mozilla and Opera zorhel ASP .Net Web Controls 0 08-23-2004 11:17 PM
Like a java applet, but using .net and made for IE, Mozilla and Opera zorhel ASP .Net Building Controls 0 08-23-2004 11:12 PM
Like a java applet, but using .NET and made for IE, Mozilla and Opera zorhel ASP .Net 0 08-23-2004 11:12 PM



Advertisments