Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. Firefox is the odd one out

Firefox is the odd one out

Scheduled Pinned Locked Moved Web Development
javascriptquestion
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Jeslan
    wrote on last edited by
    #1

    I was writing some Javascript to clear a file uploader, and the following code will clear it on IE 7, Safari 3.1.2, and Opera 9.51:

    document.forms[0].ctl00_ContentPlaceHolder1_fuTestFile1.outerHTML = document.forms[0].ctl00_ContentPlaceHolder1_fuTestFile1.outerHTML;

    On Firefox 3.0.1, that code does not work. However, the following code works on Firefox only and none of the other browsers:

    document.forms[0].ctl00_ContentPlaceHolder1_fuTestFile1.value = '';

    Do any of you find Firefox to be the odd one out very often?

    G S 2 Replies Last reply
    0
    • J Jeslan

      I was writing some Javascript to clear a file uploader, and the following code will clear it on IE 7, Safari 3.1.2, and Opera 9.51:

      document.forms[0].ctl00_ContentPlaceHolder1_fuTestFile1.outerHTML = document.forms[0].ctl00_ContentPlaceHolder1_fuTestFile1.outerHTML;

      On Firefox 3.0.1, that code does not work. However, the following code works on Firefox only and none of the other browsers:

      document.forms[0].ctl00_ContentPlaceHolder1_fuTestFile1.value = '';

      Do any of you find Firefox to be the odd one out very often?

      G Offline
      G Offline
      GibbleCH
      wrote on last edited by
      #2

      shouldn't you be writing

      document.forms[0].ctl00_ContentPlaceHolder1_fuTestFile1.outerHTML = '';

      1 Reply Last reply
      0
      • J Jeslan

        I was writing some Javascript to clear a file uploader, and the following code will clear it on IE 7, Safari 3.1.2, and Opera 9.51:

        document.forms[0].ctl00_ContentPlaceHolder1_fuTestFile1.outerHTML = document.forms[0].ctl00_ContentPlaceHolder1_fuTestFile1.outerHTML;

        On Firefox 3.0.1, that code does not work. However, the following code works on Firefox only and none of the other browsers:

        document.forms[0].ctl00_ContentPlaceHolder1_fuTestFile1.value = '';

        Do any of you find Firefox to be the odd one out very often?

        S Offline
        S Offline
        Shog9 0
        wrote on last edited by
        #3

        Jeslan wrote:

        Do any of you find Firefox to be the odd one out very often?

        No. I develop in FF initially, so code that uses outerHTML never works. ;) Given that your first technique is essentially just a quick way of re-writing the <input> element, you should be able to accomplish the same thing explicitly using the DOM:

        function dofilereset(fileInputId)
        {
           var f = document.getElementById(fileInputId);
          
           var attrsToCopy = ['type', 'id', 'class', 'style', 'name', 'size', 'title',
        'align', 'accept', 'tabindex', 'accesskey'];
           var newF = document.createElement("input");
           for (var i=0; i<attrsToCopy.length; ++i)
              newF.setAttribute(attrsToCopy[i], f.getAttribute(attrsToCopy[i]));
          
           f.parentNode.replaceChild(newF, f);
        }

        Citizen 20.1.01

        'The question is,' said Humpty Dumpty, 'which is to be master - that's all.'

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups