javascript

How to randomly change inline images on page load and each refresh, using jquery?

What is the best lightweight way to randomly show inline images from a folder on each refresh or on load a page ? using jQuery. like jQuery version of this http://javascript.internet.com/miscellaneous/random-image.html Update: 24 April This is exactly what i want i just need unobtrusive jQuery version of this <div class=”me-box”> <...

Switch case in jquery

Am I writing the correct switch case? var cnt = $("#div1 p").length; alert(cnt); switch (cnt) { case (cnt >= 10 && cnt <= 20): alert('10'); break; case (cnt >= 21 && cnt <= 30): alert('21'); ...

JQuery: How do I determine if a slideToggle has been toggled?

How do I do the following pseudo code in JQuery? $(document).ready(function(){ $(".btn-slide").click(function(){ $("#divToSlide").slideToggle("fast"); if ($(this).isToggled) { // <---- DOESN'T WORK ------- // do something when toggled } else { // do something different when not toggle...

Encoding conversation UTF-8 to 1251 in javascript

I need to convert string in UTF-8 to byte array in 1251 codepage in JavaScript. Google says nothing useful. Help :) EDIT: What is it for. We have server and client. Server has userpasswords hased with SHA512 and 1251 codepage. Client (web browser) has to hash passwords (provided by user in plain text) with SHA512 and transmit it to t...

JQuery: How do I use the JQuery delay with my own function?

How do I use the JQuery delay in conjunction with my own defined function, pseudo-code like so?: $('#foo').slideUp(300).delay(800).myOwnFunction(1,2,3); function myOwnFunction (a,b,c) {...} The code above doesn't work, however - per the JQuery documentation it appears like it should. ...

Extremely strange glitch in Chrome - parses contents of string!

Okay - this is the dumbest glitch I have seen in a while: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt; <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <script type='text/javascript'> var data = "</script>"; </script> </head> <body> This...

JQuery: How to use an HTML ascii arrow for a toggle indicator?

I came across this great JQuery example of using a slidetoggle. I want to implement it exact as is, except for one thing. The example uses an image for the Up and Down (white) arrow indicator. Can't I use the HTML ascii up arrow () and down arrow () instead of using an image. If so, how? ...

My website crashes Firefox. What do I do?

My website doesn't use Flash or any plugins; just javascript (jQuery, Google Maps). It doesn't crash FF 3.6 all the time, but it usually does after a few minutes. It can happen on lots of different pages. Sometimes it crashes when I'm scrolling the page, sometimes when I'm interacting with a control. Where do I even start debugging? Sho...

How to write JavaScript to a separate window?

I have opened a new window with JavaScript: var newwin = window.open('','preview','width=600,height=500'); Now I want to write some JavaScript to the window: newwin.document.write("<script type='text/javascript'>alert('Hi!');<" + "/script>"); newwin.document.close(); However, the script never gets executed. Am I doing something wro...

setInterval vs setTimeout

i want to know main difference between setInterval vs setTimeout in javascript? ...

[CPAINT Error] invalid HTTP response code '404'

We are trying to install: http://www.activecampaign.com/activespell/ But are getting this JS error: [CPAINT Error] invalid HTTP response code '404' It seems the ajax is unable to access something, but not sure what or why, anyone experienced this problem before? ...

Closing the gap between 2 inline elements

I have a simple div element that contains another div element which contains 2 inline tags. I've associated an onmouseout event to the first div container and an onmouseover event to the second container. The problem is that the onmouseout event is fired when the user hovers their mouse between the two tags in the div and also after ...

Ordering DOM elements

Given two DOM elements, say a and b, how can we determine which comes first in the document? I'm implementing drag and drop for a set of elements. And the elements can be selected in any order, but when they are dragged, these elements need to be moved in the "correct" order. ...

Pushing reference of an object to array

As far as i can see in a situation like this: var x = []; var y = {}; y.someProp='asd'; This doesnt work: x.push(y); What I want to do is add a reference of y to x so that later if I will "delete y;" I want it also to be removed from the array x. ...

I expect to see in the browswer "http://path/some_page.html" but instead it identifies with "http://localhost:8080/some_request"

I am developing with app engine SDK. I have a feeling this is much too basic a question so apologies ahead of time... A simple submit button doesnt work instead of just showing an alert box as expected it continues on afterwards and redirects me to the latest http-request, and I think this is because I dont understand how to tell the br...

how to perform click to the output of ActionLink by jQuery or javascript?

<%= Ajax.ActionLink("Edit", "Update", "Home", new { id = item.mID }, new AjaxOptions { OnBegin = "function(){ $('#edit" + item.mID + "').show();}", HttpMethod = "get", UpdateTargetId = "edit" + item.mID })%> The above code generates the html source code. when user click the link, it works well. But there're so many links there, I must ...

PHP uploads and checking

Hi all, Edited: Sorry for the inconvenience, when i look back the codes, it does not actually upload the files, it's only capture the file's info and store in the database, which later cannot be download by user coz there not exist such file anywhere... my questions is, how can i integrate this codes with move_uploaded_file() function?...

Get number of checkboxes that are checked in Javascript

I am trying to make a javascript function (although jquery is perfectly OK) that will return a number that corresponds to the number of checkboxes checked in a form. Seems simple enough but I can't figure out a good way of doing it. Thanks. ...

Associations and the Grails webflow

Hi, it's my first time using webflows in Grails and I can't seem to solve this. I have 3 domain classes with associations that look something like this: class A { ... static hasMany = [ b : B ] ... } class B { ... static belongsTo = [ a : A ] static hasMany = [ c : C ] ... } class C { ... static belongsTo = [ b : B ...

Internet explore is unresponsive while loading a large page

We have a html page being rendered in the browser (IE) that causes the browser to hang. The page is generated through server side script (ASP.NET and viewstate is disabled). The page while loading takes a long time (its not a b\w issue since we can reproduce it on local machine) and sometimes results in script unresponsive error. On deb...