javascript

Javascript: Module Pattern vs Constructor/Prototype pattern?

Hi there, I have been reading a little bit about the Module pattern and i wonder if applicable for what i need to do or should i use the Constructor/protoType pattern. Basically I am using unobstrusive javascript so i have a reference to my .JS file in my HTML document. If i understand it correctly then I can call a INIT method (which...

Help with javascript onchange and showing/hiding table content

I'd like to show / hide a div within a td tag based on the select value chosen. I cannot get the label text to appear, only the textbox. Can someone please give me a hand with this? Here is my code so far <script> function toggleOther(chosen){ if (chosen == 'oth') { document.myform.other.style.visibility = 'visible'; } else { docum...

Hiding the HTML5 number input spin box

Is there a consistent way across browsers to hide the new spin boxes that some browsers (such as Chrome) render for HTML input of type number? I am looking for a CSS or javascript method to prevent the up/down arrows from appearing. ...

javascript / jquery: how do I get the inner window height?

Like... the height that excludes the address bar, bookmarks, etc. just the viewing space. $(window).innerHeight() appears to not work. ...

How do I determine if something has been clicked in jQuery on the first load?

I am trying to set a javascript variable to be one of a few options. If one of a few specific link shas not been clicked (i.e. the first page load), then the variable should be set to 0 or 1 (the default value). If it has been clicked, then I want it to get a number associated with that link. So say the html looks like this: <a href=...

when mousing over a link I want the div that contains the link and other content to increase in height then back down to 19px on mouse out

I'm customizing forum software each page has 20 threads each thread is contained inside a div whose class="threadpreview" inside of each "threadpreview" divs are the LINKs to the full thread, and a 500 character preview of the thread right beneath the link when the page loads up, I have all the divs' height set to 19px and overflow:hid...

creating an inline update field using jquery

Hello all. I've gotten stuck(again) I have a table and one of the columns is a value that I want to be able to click, turn into an input field, then click again to change it back to just text. I've gotten the first step done. It turns into an input field with a link to click and it uses the value that was previously in the td. Howeve...

a single equals in an if. Javascript. Any good reason?

jQuery.each(player, function(key, val){ if (el = $("#pr_attr_plain_"+key)){ el.text(val === "" ? 0 : " " + val); } }); I inherited a project and I came across something strange. The guy who started the project is an expereinced programmer, definitely more so then myself. Is there any value or r...

Reuse object within another object

I have an object that contains another object with translations. It looks like this: var parent = { //parent object with a bunch of stuff in it countryAlerts:{ //area for country alerts "USA":{ //country en:"FAST", //alert text in English es:"RAPIDO" //alert text in Spanish }, "Japan":...

Why were window.scrollY and window.scrollX introduced?

As far as I know, pageY/XOffset properties were already available since Netscape 4 era. And it seems scrollY/X were introduced circa Netscape 6. Alternative question: Is there a browser which implements scrollY/X but doesn't support pageY/XOffset? ...

refresh a javascript file after an event?

I am using a keynav plugin that allows me to navigate up and down though a list. This list is dynamically generated using ajax and mysql. the suggesstions appear when someone begins to search into an input box. if the user clicks off and the list closes and then begins a new search, when the list is generated the second time, the keybo...

jquery .each() take image and title from a class and add each one to 5 diffrent div's

I am stuck on this what I am trying to do is: there will be div's with the class of feature there could be an x amount of them but i only want 5 most resent. take the img src and a.html witch is a title link from each and add each one to 5 containing divs at the top of the page. the image as a background-image and the other prepend to an...

user paste a hyperlink and picture into a text area

I have a website that has in internal email system . There is a text area for the body of the email. but what I need to do is allow the user to paste a link or picture into the area. can this be done ? or is there a script etc.. Any help would be appreciated ! thanks ...

Pros and Cons of function-level scope (Specifically in Javascript)

What are the pros and cons of function-level scope specifically in Javascript compared to block-level scope in languages like Java? I would like to see examples of function-level scope usage that would be harder or impossible to implement using block-level scope. ...

How do I know if the user clicks the "back" button?

I'm using anchors for dealing with unique urls for an ajaxy website. However, I want to reload the content when the user hits the Browser's "back" button so the contents always matches the url. How can I achieve this? Is there a jQuery event triggering when user clicks "Back"? ...

Comparing native javascript objects with jQuery

I have two native JavaScript objects: var foo = { hello: 'world', holy: { shit: 'batman' } }; var bar = { ... }; I would like to compare the two (foo == bar). ...

Javascript : How should I run one `for`, for two arrays?

I have: var array1 = []; var array2 = []; array1 contains 1,2 array2 contains 3,4 And I want to do this: for(var a in array1){ for(var b in array2){ doSomething(array1[a],array2[b]); } } But the problem is that function doSomething() runs twice for each array because of the two for's. How should run it just once...

IE not implemented javascript error

I'm using some basic jQuery at http://s329880999.onlinehome.us/ and I'm getting a "not implemented" error in Internet Explorer. I'm guessing that this is to do with my using top (var s2). How can I make it work in IE? ...

Why is Chrome dying on this page?

If I open this page in Chrome 6.0.472.62 or .63 for OSX, the Javascript interpreter hangs. If I open the developer console to debug the problem and then open the page, the page runs fine. Running with the developer console results in no logging statements, so I'm fairly sure that it's not a problem with console.log not being defined. I'v...

catching exceptions in Javascript thrown from ActiveX control written in C++

I've written an ActiveX control in C++ that throws (C++) exceptions out when error conditions occur within the control. The Javascript code that invokes the object representing an instance of the control is surrounded by a try - catch block: try { var controlInstance = window.controlInstance; ... perform operations on controlIn...