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

T

Tim Slattery

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?
 
M

Martin Honnen

Tim said:
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 said:
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.
 
T

Tim Slattery

Martin Honnen said:
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.
Note that JavaScript comments are done with
//comment
or
/*
comment
*/


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

Unfortunately, its a restricted system.
 
V

VK

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,190
Members
46,736
Latest member
zacharyharris

Latest Threads

Top