Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9218473
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T02:52:20+00:00 2026-06-18T02:52:20+00:00

I have a DIV when i click on it it will trigger a javascript

  • 0

I have a DIV when i click on it it will trigger a javascript to click on file upload button which was display:none. It works on my pc with Chrome, Firefox, Chromium. But I wonder why it does not work on my friend pc.

Is it because the browser issue or what? Me and my friend using
different version of Ubuntu. Nothing happen when they click on the DIV

Here is my code

<div onclick='uploadphoto()' title='Click to edit Profile Picture'></div>

<form action="js/ajaxuploadprofile.php" method="post" name="sleeker" id="sleeker" enctype="multipart/form-data" style='display:none'>
    <input type="hidden" name="maxSize" value="2000000" />
    <input type="hidden" name="maxW" value="700" />
    <input type="hidden" name="fullPath" value="images/profilepic/" />
    <input type="hidden" name="relPath" value="../images/profilepic/" />
    <input type="hidden" name="colorR" value="255" />
    <input type="hidden" name="colorG" value="255" />
    <input type="hidden" name="colorB" value="255" />
    <input type="hidden" name="maxH" value="700" />
    <input type="hidden" name="filename" value="filename" />
    <input type="file" id='filename' name="filename" onchange="ajaxUpload(this.form,'js/ajaxuploadprofile.php?filename=name&amp;maxSize=2000000&amp;maxW=700&amp;fullPath=images/profilepic/&amp;relPath=../images/profilepic/&amp;colorR=255&amp;colorG=255&amp;colorB=255&amp;maxH=700','upload_area','File Uploading Please Wait...&lt;br /&gt;&lt;img src=\'images/loader_light_blue.gif\' width=\'128\' height=\'15\' border=\'0\' /&gt;','&lt;img src=\'images/error.gif\' width=\'16\' height=\'16\' border=\'0\' /&gt; Error in Upload, check settings and path info in source code.'); return false;" />
</form>

<script type='text/javascript'>
function uploadphoto()
{
    el = document.getElementById('filename');
    if (el.onclick) 
    {
       el.onclick();
    } 
    else if (el.click) 
    {
       el.click();
    }
//$('#filename').click(); // <-- this also works for me but not my friend
//document.getElementById('filename').click(); // <-- same
}
</script>

Updated Solution

Recently I found out that style='display:none' will have some issue in some browser (or maybe due to the version of the browser). For my case, the version of Chrome is different between mine and my friends and hence it works on my pc but not my friends’ pc. However, I am able to solve this problem by replacing style='display:none' with style='visibility:hidden;height:0px'. the code now is working fine in any pc.

visibility:hidden is just hide the view for the content, it will still occupy some space. Hence i added height:0px so that it will have same effect like display:none.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T02:52:22+00:00Added an answer on June 18, 2026 at 2:52 am

    It can be a browser issue. For an example it might cause problems in IE. If you are using jQuery, you can do as below:

    $('#button').trigger('click');
    

    Or else you can try as below:

    if( document.createEvent ) {
        var evt = document.createEvent("MouseEvents");  
        evt.initMouseEvent("click", true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);  
        document.getElementById('button').dispatchEvent(evt);
    } else if( document.createEventObject ) { // For IE 8 and below
        var evObj = document.createEventObject();
        document.getElementById('button').fireEvent('onclick', evObj);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a div which opens when I click a menu button, I am
I have a div that I want when user click on a button slideUp
I have a DIV which I want to be removed when I click a
I have a div show hide function which is working fine. when I click
I have a div that I click on to drag it. Once it's on
When you have a div with a click handler attached, the iphone darkens the
I have a div inside a table cell. When I click in the table
I have following div in a page (I can not modify). <div id=:0.control>Click me</div>
I have a question about jQuery load best practice. Imagine the following situation: $(#div).on('click',
I'm using colorbox on a div. I have nested div's. When i click the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.