javascript

Baffling Safari Javascript Issue

My code below works in firefox perfectly..but not in Safari. When I use the Safari debug it simply says there is a parse error, just after the first opening curly bracket { function setVals4(class,val) { var array = document.getElementsByTagName("select"); for (var g = 0; g < array.length; g++) { sel = array[g] ...

Algorithm (or regular expression) needed to find multiple instances of anything

I'm not sure if there is a simple way of doing this, but is there a way to find multiple instances in an unknown string? For example: hellohellohellobyebyebyehello Without knowing the value of the above string, can I return something that will tell me that there are 3 instances of "hello" and 3 instances of "bye" (I'm not worried abo...

Good way to output javascript selectively depending on Application settings

I am developing a site which includes several different javascript files and libraries. For optimization purposes I have implemented YUI Compressor for .Net This will minimize and combine my javascript files into one single file. Now I have put this up in a MSBuild script that automatically does the compression and minimization and out...

How to match external links with javascript (but ignore subdomains)?

I have the following (jquery) selector looking for external links. This works, and ignores all links that include location.hostname (e.g. www.domain.com) My question is, how to extend this to also ignore links to subdomains of your site? (e.g. new.domain.com) $('a').each(function() { var href = $(this).attr('href'); if(this....

DOM Storage expires time

How many days data, stored in localStorage (as a part of Dom Storage HTML 5) available? Can i set expires time for data which, i puts to localStorage? ...

Control an embedded video through javascript

How would I go about seeking or pausing an embedded video (not necessarily a swf) from javascript? I am looking for something like Google's SWFObject's API, but for Windows Media Player, Real Player, Quicktime. ...

YUI datatable error

Hi, I'm trying to put together an application which uses YUI's DataTable component but I get the "Data error" message. The datasource is configured to get the records from an ASP.NET web method. The records are returned to the client side successfully (I checked it with IE's debugger). My code looks like the following: YAHOO.example.Ba...

jquery val() failing on dynamically generated input

I have the following dynamically created html block: <form class="standard settingsPage" method="post" enctype="multipart/form-data" name="account" style="background-color: rgb(61, 80, 133);"> <h2>Add New Account</h2> <p> <label class="" disabled="true">E-mail address:</label> <input id="accountEmailAddress" class="" type="text" value="...

Change Dynamically Data Source's xml source on Dashcode.

Classic StackLayout-List(s) scenario. StackLayout have: Home - Detail - Leaf On "Home" I have a Datasource like this: <row><name>Element 1</name><resource>../Element1.xml</resource></row> <row><name>Element 2</name><resource>../Element2.xml</resource></row> This is binded to a list of name "homeList". onClick on "Element 1" i load ...

Store variable based on if statement with jQuery selectors

I'm new to both Javascript and the framework jQuery. Basically I'm trying to say that if the quantity is greater than 1 then don't charge a fee. However if it is equal to 1 charge a fee. But I don't know how to store the variables while using jQuery. My thought was... (is this correct?) var qty = $(".qty_item"); var price = $(".price_...

IE8 getJSON cached data

Simply one really. IE8 is caching my data so it works first time but not afterwards. I need to stop it using cached data when i call getJSON? P.S Im currently debuging my site in IE so expect lots of posts from me :) Thanks for all that have helped so far truely are a great help! ...

One page web apps and inline javascript and CSS

We've built what is called a one page web app(a single html page + ajax) In the pursuit of shaving as much http calls as possible, we bundled the JS and CSS in 2 files. Meanwhile we took a look at the way Google Buzz for mobile is built and there are some interesting points: inline SCRIPT and STYLE no external JS and CSS data:images ...

Look for div# in the response, if data is 1

I am using this script to insert comment to the database: var http = createObject(); var nocache = 0; function insert() { document.getElementById('insert_response').innerHTML = "To Sek .. " var fID= encodeURI(document.getElementById('fID').value); var kommentar= encodeURI(document.getElementById('kommentar').value); nocache = Math.rando...

jQuery.find() IE7 bug?

I have a few lines of code where I use this function, but it seems to only find the 1st element in IE7. Works in IE8/FF/Chrome. $(document).find("#JobID").attr('checked', $('#CheckAll').is(':checked')); I also have a similar line which only finds the first element. $(document).find("#JobID").each(function() { ... } Does anyone know...

JS function for writing out a word, binary counter style

How can I create a loop to output any given word like this: ...if the word is 'abcd' a--- -b-- ab-- --c- a-c- -bc- abc- ---d a--d -b-d ab-d --cd a-cd -bcd abcd in other words, letters appear in binary counter order 1000 0100 1100 0010 1010 etc. Thanks ...

Javascript scrollbar based on browser window size

Hi there, I have a Flash file embedded into HTML - the objects inside are place based on the browser's screen size. Most of the time I don't want a scroll bar, as things are correctly placed, but once the browser window gets too small it'd be nice to have it. So, the main question: can I have a Javascript code listening for the browse...

JavaScript: Navigate to a new URL without replacing the current page in the history (not window.location)

I know how to use window.location. The problem is that, (at least in FF) it erases the page you are on from the history. e.g., I'm on page A, I navigate to B and window.location is used to send me to C. If on page C, I click back, I end up at A, not B. Is there some other way to navigate to another page without erasing the current page ...

JQuery Tabs UI - Menu rotation - OnMouseOver and OnMouseOut

Hi, I am currently working with a tab menu which cycles through automatically. Once I mouseover one of the tabs the "rotation" should stop on the selected tab and when I mouseout it should continue rotating from the selected tab item. $("#featured > ul").tabs({ event: 'mouseover', fx: { opaci...

How to know when all AJAX calls ended

Hi, I have an ASP page, which on load fires a bunch of AJAX calls. How can I detect in javascript that all AJAX calls finished? The ajax calls are made using AJAXPRO library. I need this in order to execute some event. Thanks, Adrian ...

Forcing external javascript files (from Digg, Reddit) to load last

I'm working on a WordPress site that has two external javascript files load about half-way down the page. The files are badges from Reddit and Digg, and often add about 4-8 seconds to the total loading time of page — while also preventing the bottom 50% of the page from loading too. The Digg and Reddit javascripts render an <iframe> (wh...