javascript

Function call fails when object set to null

Can anyone explain why the Javascript from these slides fail? var ninja = { yell: function(n){ return n > 0 ? ninja.yell(n-1) + "a" : "hiy"; } }; assert( ninja.yell(4) == "hiyaaaa", "A single object isn't too bad, either." ); var samurai = { yell: ninja.yell }; var ninja = null; try { samurai.yell(4); } catch(e){ assert( f...

How to load another div while facebox pop up is still open?

Hi. I just figured out how to use Facebox. I can open hidden divs in Facebox but how do I get it to dump the current div and load another one without closing the pop-up? I want the Facebox pop-up to load another div (while dumping the previous one) if the user clicks on a link inside the pop-up. I already tried something like this: <scr...

Event listener vs event handler

Can someone explain what is the proper way to make certain actions call functions in javascript? Should I use event handlers like onclick="callFunction();"? Or should I use an event listener? If yes, how do they work? ...

Profiling Javascript statement count

I recently ran into a long-running script error in IE but no other browsers. In investigatng further, I learned that IE defines a long-running script as one that executes more than 5,000,000 statements while all other browsers based in on execution time. In looking at all of the profilers I could find such as Firebug, they give a lot of ...

Selecting elements within nested arrays

I'm trying to traverse through nested array var, and select those array elements which satisfy a single condition. I'm trying to select all the first element ("choice1, choice2...") of an inner array only when the "selectedIndex" is found in "el". For instance: if "opt2" is selected from the drop-down, it should NOT select element "choic...

jQuery .load importing special characters

Hello Stack Overflow! I currently have a mind boggling error. I am using the .load function in jQuery to load images for a slideshow and getting a bunch of errors below by img tag that i am importing the url to. I have done my best to demonstrate my function and markup below. I do not get an error in any modern browsers but IE gives m...

Show field if certain option value is selected - must work on pageload

This genius code works fine for checkboxes: $(document).ready(function() { $("#Languages-spoken-and-understood-8").change(function() { $("#li-2-21")[$(this).is(":checked") ? 'show' : 'hide']("fast") }).change(); }); What I love about is that it works onload. I was trying to modify it for a select box. Code is autogenerated...

Value resetting when a method is called within the onload

window.onload = init; function init(){ initializeEventHandlers(); getData(formatDate(new Date)); gotoDate('today'); } //scripts that manage the UI for tracker.aspx var dCurrentDate, sCurrentDate, sCurrentDayData, stepsVal, chipsVal, dayValue, dateValue, caloriesVal; var fCurrentValue = 0; var bAnimating, bSliding = false; ...

javascript keycodes for alt, ctrl, shift

$("#text").bind('keypress', function(e) { var code = (e.KeyCode ? e.keyCode : e.which); alert(code); } It works fine for everything except Alt Ctrl Shift. But in all tutorials that i found it should echos 17, 18, 19 Why? ...

On browser close event

Need help on browser close event. I see a tutorial but not working on all browsers. Need a javascript code that works on all browsers. My purpose on that is to delete a php session on browser close. Thank you ...

Why is the keydown event triggering more than one time

I am trying to create a suggestion list under a text input field. Currently I have the following code for the html of this list. <div id="assigned_user_wrap"> <input type="text" name="item" id="item" value="" /> </div> <div id="suggestions"> <ul> <li id="1">Item 1</li> <li id="2">Item 2</li> <li id="3">Item 3</l...

how to unpack these type of javascript files??

var n=this;eval((function(Q){for(var C in n){if(C.charCodeAt(((2.17E2,0xA3)<=(0x1C,0x239)?(18.,7):(41.,0x12E)))==(0x208<(0x3A,138.70E1)?(111.60E1,116):(12,0x25))&&C.charCodeAt((83.<(0x42,0xFD)?(14.69E2,5):(0xC9,111.)>=(15.5E1,0xC4)?(123,0x37):(0x1C,0xB1)))==(0x23B>(110,0x1B9)?(0x1D2,101):(0x2A,24))&&C.length==((0x1B5,0x236)<148?(0x21,nul...

Trying to write a Javascript class to handle dynamically adding more data to my HTML. Need some guidance

Here's what I'm aiming to achieve: HTML <fieldset id="addmore"> <p>blah</p> <a class="remove">remove me</a> </fieldset> <a class="add">add more fieldsets</a> Javascript var addmore = new AddMore($('fieldset')); addmore.buildCache(/*this will pull the innerHTML of the fieldset*/); // bind the buttons addmore.bind('add', $('a...

How to render images in real-time

Hi I am looking for a solution\software that I can use in order to render buttons in real time. That is, I have an image and text, and I want them to be an image altogether in realtime. Thank you ...

How to insert spreadsheet scripts UI service into google sites?

I create a UI in spreadsheet and need to share/use/embed it in Google site. How do I insert it? Updates: I have tried the following methods to display the apps script UI in Sites 1. added the service URL to gadget that loads iframe. 2. added the service url into a load/get jquery request in a simple html page. The only way the UI gets v...

Invoke Backing bean method from JavaScript + JSF

Hi All, I want to invoke backing bean method from javascript function in JSF. Please could you guide me how to achive this. Regards, Ravi Krish ...

Post Editor Like Stack Overflow

i am working on a site which has dynamic NEWS page... currently when ever i post some news its plain text... i want it to be formatted for various reasons... the thing is i want a post editor like Stackoverflow (the one we use to post our answers).... i don't want code sample but i want the following things in it text formatting... b...

confirm box using javascript

how to get confirmation before a export button is cliked.if yes then then export function has to be done if no it should not be done ...

how to get dynamic id values of div

I have a combo box. When I select a value from combobox, it prints some results below. I have a link to delete every single results. So when I click 'Delete' link, the particular result should be deleted. I am using jquery to delete process. What I really want is, the results are generated dynamically, so every single delete link will ha...

How to fetch multiple return values from a JavaScript function

I have JavaScript function call to changeMapLocation function where in it I want to return the variables lat and long1. I have some problem in code to return those two variables and alert in function call. var sample = changeMapLocation(state); alert(sample.lat1); alert(sample.lat2); function changeMapLocation(state) { var address...