javascript

Javascript 'this' value changing, but can't figure out why

I'm a total Javascript newb, and I'm trying to wrap my head around OLN. What I'm encountering is that, when calling an object method from another method on the same object, the value of local value of 'this' in the called method is changing. Here's my code: var generator = { generateForLevelSkillAndCount : function(level, skill, cou...

Iteration over jquery object returning string instead of dom elements

I have the following loop: for(var myScreen in wizardScreens){ if(step==index)$(myScreen).show(); else $(myScreen).hide(); index++; } wizardScreens is defined as $(".wizardScreen", wizard);, where wizard is a DOM element. Within the loop, myScreen is set to a string, instead of being a DOM element. Can anyone explain why t...

Browser-based visual editor/designer?

Is there an example of a browser-based and preferably open source visual javascript application designer (using contenteditable or canvas or whatever), perhaps with support for embedded controls and so forth (checkboxes, buttons, etc., or ui controls for various javascript frameworks like jquery.ui, dojo, yui,...), OR else support for ve...

a more readable way to do this?

Hi there. I know there is a more readable way of writing this: var string = ( (r.d != 0 ? r.d + (r.d == 1 ? ' day' : ' days') : '' ) + (r.h != 0 ? r.h + (r.h == 1 ? ' hour' : ' hours') : '' ) + (r.m != 0 ? r.m + (r.m == 1 ? ' minute' : ' minutes') : '' ) + (r.s != 0 ? r.s + (r.s == 1 ? ' second' : ' seconds') : '' )); ...

JQuery html() vs. innerHTML

Hi, Please tell me, Can I rely completely upon jquery html() method that it'll perform like innerHTML? is there any difference between innerHTML and jquery html() method? and if these both do the same work can I used jquery html() method in place of innerHTML? My problem is: I am working on already designed pages, the pages contains ta...

What does var x = x || {} ;

what does the following code do in java script: var x = x || {}; ...

Store front-end features in Rails?

In the public folder we have stylesheets, javascripts and images. I want to add a front-end feature that has it's own css, js and images, but according to this hierarchy i have to store them like this: stylesheets/calendar/main.css javascripts/calendar/cal.js javascripts/calendar/cal2.js images/calendar/front.jpg images/calendar/button...

addClass("test") doesn't work - but css("background","red") does.

Anyone know why? Here's the JS: $(".screenshots .tab1").hover(function() { $(".section1").addClass("test"); }, function() { $(".section1").removeClass("test"); }); }); And the CSS: .test { background: black; border: 1px solid #ffb75b; background-color: #fffadb; } ...

Finding highest z-index of all elements

I need to implement an alert-type modal popup that appears with a dimmed background. The problem is, we may have other elements on the page being showed that are also modals with z-indexes above default. How do I determine the appropriate z-index that makes a given element the highest-layered element? (jQuery is fine.) ...

Javascript condition based on Rails variable

I want to set a global constant (in Rails) and then depending on that I want to put a condition in a JavaScript file (which is included in every page of my app). I also have some Rails dependent code based on this variable. What is the best way to do this ? ...

extract file full path using javascript

Hi, I am working on photo uploader.I have a requirement like when user select photo from Desktop. I need to show photo and name both before he will start click on upload.The reason being showing the photo at client side is because he can verify by seeing photo at first. so my problem is I m not getting the path. when i m using <i...

Problem having with java applet and Safari

My html page is using java applet and it has javascript callback functions. With IE and Firefox, we can see a hand cursor when mouse is over the link where there's javascript callback function. But with Safari, we cannot see hand cursor unless we click on java applet area to activate the applet. Please advise if you have a solution that...

Save a browser image to a location on the disk in Javascript

Is it possible for my intranet web application in Internet Explorer to save an image loaded into the browser to a location on the disk, without any user intervention? That is just save the image, and not ask the user where they would like to save it. As this is an intranet I'm happy to use WSH/Active Objects and make it a trusted site e...

JS/PHP: Who is responsible for generating the content?

Here's a situation which I have encountered, creating a form on the client side and using PHP to process. Here are some considerations The PHP script generates the form and send to the client side. This is because of internationalization issues The client side uses JavaScript to submit form; the ID of the form is hard-coded inside the ...

Accessible way of hiding an element until jQuery's $(document).ready()?

I have a large survey that I have made more usable with jQuery by arranging it into sections and using an accordian menu to flip through each section. The trouble is, there is a noticable snap when $(document).ready() fires and condenses everything into an accordian menu. That is to say that before $(document).ready(), you can see the w...

How to detect inactive tab and fill it with color

How can I fill my website with color if tab is inactive? I would like to give screensaver like effect to my site if user move to another window. Can I do that with jQuery? ...

How to enable scrolls when browser resized

I have simple html table on the page. I want to add horizontal-vertical scroll bars to the table when the browser is resized to continue showing the table content. How can I do this? ...

Dynamically add input with jsDatePick

If I insert new INPUT with new ID, how do I enable that new INPUT to have the calendar popup with jsDatePick? http://javascriptcalendar.org/javascript-date-picker.php Anyone tried? ...

How to determine if assets are downloading on a page?

I am attempting to observe the performance of a flash application on the client side using JavaScript. The main thing I'm interested in is if the flash application has completed downloading all of the assets it needs. Is there a way to determine if assets are still being downloaded by the browser regardless of the container downloading...

Should I use Table.cells[]?

Hi there. I'm currently trying to write some javascript to loop through the elements in a table, but was wondering what the best practise was. I could just call .cells[] on my table object to get all of the cells in the table, but the W3Schools page says that this is not a W3C standard - should I avoid it then? The other option is to us...