Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Make getElementById('blah').click(); work in FF and Opera
Old 07-15-2007, 10:49 AM Make getElementById('blah').click(); work in FF and Opera
OTO
OTO's Avatar
Experienced Talker

Posts: 44
Location: Tbilisi, Georgia
Trades: 0
Hi all!

I am newbie in JS and have already met next problem:

I've got a form:
Code:
<form method="post" action="#" style="position: relative;">
       <input type="file" id="filefield" class="invisible" value="" />
</form>
And simple img tag and can't make .click(); function work in Firefox and Opera (It works great in IE and Safari):
Code:
<img src="button.gif" onclick="document.getElementById('filefield').click();" />
Can anyone tell me how to solve this problem? thx...
__________________
Nothing Is Impossible!

Last edited by OTO; 07-15-2007 at 11:34 AM..
OTO is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 07-17-2007, 11:19 PM Re: Make getElementById('blah').click(); work in FF and Opera
Extreme Talker

Posts: 238
Location: United States
Trades: 0
It is impossible to use the click() method on an input element of type file in Firefox. (I assume Opera does the same.) The reason for this is security, although the click() method by itself is mostly harmless. Firefox actually blocks most JavaScript methods and CSS properties on input type files.

I can guess from your code samples that you are trying to replace the ugly default browse button. This can be done, but in a different method, which is based around the CSS opacity property.

See http://www.quirksmode.org/dom/inputfile.html for a tutorial on one way to do this.

Last edited by frost; 07-17-2007 at 11:20 PM.. Reason: I made a typo!
frost is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Make getElementById('blah').click(); work in FF and Opera
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.39642 seconds with 12 queries