javascript

Add a row on top of table generated by javascript

Hello all, I made a mis calculation in a table structure. The code beneath is for a lotto game (a known piece of code I think ;)) Is there a way to add a row on top of the table filled with a numbers? I really don't know how to do this. http://www.coldcharlie.nl/lotto/ <script type="text/javascript"> (function() { var players = { ...

how to catch javascript errors in all Iframes (with window.error) ?

Hi, I know one can add event listener for window.error. However when working with Iframes, each Iframe has its own window element, and window.error should be created for each and every Iframe. Is it possible somehow to define error event handler in one location ,where all errors will trigger this specific method? Thanks, Tal. ...

Calling JavaScript with PHP

I want to call a PHP function when pressing on a button, sort of like: <?php function output(){ // do something } ?> <input type="button" value="Enter" onclick="output()"/> I tried to make something like: <input type="button" value="Enter" onclick="test.php?execute=1"/> where test.php is current page and then by php <? if(iss...

Detecting an "invalid date" Date instance in JavaScript

I'd like to tell the difference between valid and invalid date objects in JS, but couldn't figure out how: var d = new Date("foo"); console.log(d.toString()); // shows 'Invalid Date' console.log(typeof d); // shows 'object' console.log(d instanceof Date); // shows 'true' Any ideas for writing an isValidDate function? EDIT - thanks fo...

Javascript to SWF on separated domains

Hi all , I have an application with embed swf thatis called from javascript using handleEvent, This was working fine when they were both on same domain but now when i seperated them it returns an error , any ideas ?? Thanks ...

DRI in jquery? - n00b question

can someone tell me how to make and call my own jquery functions? (im an absolute front end noob) take this example code :- <script> $(document).ready(function(){ $.getJSON("http://127.0.0.1:8000/json/storylist/", function(data){ $.each(data.stories, function(i,item){ $row = item.title; $('#sto...

JavaScript Auto suggest to update multiple fields

I have a simple autocomplete field that spits out a bunch of suggested words and puts it in the suggest field. Is there an auto suggest code that can enter the selected text but also auto fill a range of other fields instead of the selected field? For example, searching through a contacts list you type their name or address and it sugge...

find last names in url after # - jquery/ javascript

Hey Is there a way to get the last names after # in the url in jquery/ javascript I want to find the names #prices and make an if statment if( the_last_name == 'prices' ) // do something I need js/jquery to find a way to get urls last name ( and check it on the if statment /the_last_name) ...

jquery set html from select value not working

I have not used jquery much yet and not very familiar with it. Trying to do the below: // JavaScript Document $(document).ready(function() { $('#day').change (function () { //next to lines work here but not if placed after $.get var day = $('#day').val() ; $("#test").html(day); $.get('http://www.sharingizcari...

How to convert characters to HTML entities using plain JavaScript

I have the following: var text = "Übergroße Äpfel mit Würmern"; I'm searching for a Javascript function to transform the text so that every special letter is represented by its HTML entity sequence like this: var newText = magicFunction(text); ... newText = "&Uuml;bergro&szlig;e &Auml;pfel mit W&uuml;rmern"; The function should not...

How to move the textbox viewport when gaining focus?

Hi, I have a textbox that may contain strings larger than the textbox size. When I'm typing, the textbox "viewport" always moves to show the last character I typed (for example when you write a very large title in a SO question). a The problem is that if the texbox loses focus, when it is focused again the viewport always is set at th...

JQUERY combine 2 sloppy lines into one - with some type of JQUERY Evaluate?

I have the following 2 lines of code: var minusID = settingID + '-minus'; $('#' + minusID).removeClass("selected"); How can I efficiently combine this into one line? Thanks ...

IE 8 Frameset / Javascript error

Ok here's the problem. I have a page that works in FF3 and Safari4 no problem. It's IE8 that's causing the issue, go figure. I remember in the Netscape days when it was the opposite. Anyways, So i'm building a website for a friend - i have three pages. the first two work fine on their own, but when they are combined in a frameset ...

Alternatives to using autocomplete in forms

So the autocomplete="off" attribute is invalid HTML according to the w3c. Are there valid ways to do this in HTML, CSS or JavaScript? Or do we just have to plan on some of our forms not validating because we want to use this functionality. ...

Is HTML 5 supported by all the main browsers?

I am looking at the custom attributes feature of html 5 here at this link http://ejohn.org/blog/html-5-data-attributes/ This look like the perfect thing for when I am using jquery/javascript. My question, Is HTML 5 supported by all the main browsers? example <li class="user" data-name="John Resig" data-city="Boston" data-la...

What is the best way to obfuscate/minify dynamically generated javascript

I am looking to obfuscate and minify dynamically written javascript with ruby. Does anyone have any suggestions? Some kind of apache module that would intercept the .js file and obfuscate it before it was served would be ideal. ...

Best way to do a menu like this

Below is an image from a site that hase user photo's, they link to a profile but on the image you will see a + sign, this part links to add a friend. I am wanting to do something similar but instead of just having the plus sign part be a link, I am wanting to click the plus sign and have a couple of links appear, kind of like a dropdo...

Python code to download a webpage using JavaScript

Hi, Im trying to download share data from a stock exchange using python. The problem is that there is no direct download link, but rather a javascript to export the data. The data page url: http://tase.co.il/TASE/Templates/Company/CompanyHistory.aspx?NRMODE=Published&amp;NRORIGINALURL=%2fTASEEng%2fGeneral%2fCompany%2fcompanyHistoryD...

Remove an attribute from a blob of HTML with jQuery

I have a blob of HTML. How can I use jQuery to remove the class attribute from all anchor tags in the blob and then return the resulting HTML? I feel like this should work, but it doesn't: $(blob).filter('a').removeAttr('class').end().html() (It returns the empty string) Bonus points if you explain why my solution is wrong. ...

General unit testing concepts/practices in JavaScript against different browsers?

I’ve been writing unit tests in strongly typed languages and I have a fair good understanding about it. When writing unit tests in JavaScript to verify if certain functions are working properly in certain browsers I am back to the manual testing. I have no understanding of how it works. Because JavaScript is meant to close the gap betwee...