Style input type file? [duplicate]

Follow these steps then you can create custom styles for your file upload form: 1.) This is the simple HTML form(please read the HTML comments I have written here bellow) <form action=”#type your action here” method=”POST” enctype=”multipart/form-data”> <div id=”yourBtn” style=”height: 50px; width: 100px;border: 1px dashed #BBB; cursor:pointer;” onclick=”getFile()”>Click to upload!</div> <!– this is your file … Read more

Cross-platform, cross-browser way to play sound from Javascript? [duplicate]

You will have to include a plug-in like Real Audio or QuickTime to handle the .wav file, but this should work… //====================================================================== var soundEmbed = null; //====================================================================== function soundPlay(which) { if (!soundEmbed) { soundEmbed = document.createElement(“embed”); soundEmbed.setAttribute(“src”, “/snd/”+which+”.wav”); soundEmbed.setAttribute(“hidden”, true); soundEmbed.setAttribute(“autostart”, true); } else { document.body.removeChild(soundEmbed); soundEmbed.removed = true; soundEmbed = null; soundEmbed = document.createElement(“embed”); … Read more

What requests do browsers’ “F5” and “Ctrl + F5” refreshes generate?

It is up to the browser but they behave in similar ways. F5 usually updates the page only if it is modified. Modern browsers sends Cache-Control: max-age=0 to tell any cache the maximum amount of time a resource is considered fresh, relative to the time of the request. CTRL–F5 is used to force an update, … Read more

How is the default submit button on an HTML form determined?

If you submit the form via JavaScript (i.e., formElement.submit() or anything equivalent), then none of the submit buttons are considered successful and none of their values are included in the submitted data. (Note that if you submit the form by using submitElement.click() then the submit that you had a reference to is considered active; this … Read more

Fixing JavaScript Array functions in Internet Explorer (indexOf, forEach, etc.) [closed]

Many use the MDC fallback implementations (eg. for indexOf). They’re generally rigorously standards-compliant, even to the extent of explicitly checking the types of all the arguments. Unfortunately whilst it is clear that the authors regard this code as trivial and freely-usable, there doesn’t seem to be an explicit licence-grant to put this in writing. The … Read more

Cross-browser window resize event – JavaScript / jQuery

jQuery has a built-in method for this: $(window).resize(function () { /* do something */ }); For the sake of UI responsiveness, you might consider using a setTimeout to call your code only after some number of milliseconds, as shown in the following example, inspired by this: function doSomething() { alert(“I’m done resizing for the moment”); … Read more

Memory leak risk in JavaScript closures

I used to work with the ex-program manager for JavaScript within Microsoft, on a non-browser EcmaScript (err.. JScr… JavaScript) project. We had some lengthy discussions about closures. In the end, the point is that they are harder to GC, not impossible. I’d have to read DC’s discussion of how MS is ‘wrong’ that closures cause … Read more