javascript

How can Javascript mask whether radio button is checked?

Is it possible with Javascript to hide the checked-status of a radio button so that on a form submit the submit-request fails b/c of missing information? For example: I have a group of radio buttons <form action="?modul=daDaaaah&subModul=someCoolThingy" method="post"> <input type="radio" name="mygroup" id="nod_1" value="great" /> ...

javascript equivalent of ASP preInit event

Hi guys, searching for this has yielded no resuts.. i have a middle page that has an iframe and all the pages open in that iframe...i have to implement a chat system just like in Google and so to ensure that the chat windows did not close whwn the page would postback i am opening all pages in iframe.... this is a social networking sit...

JQuery/JS question: how can I change "x" everytime a bind is called?

I would like to change the variable x to 3 every time the window gets resized. $(document).ready(function () { var x = $("#display_piece_big_frame").offset().left; $(window).bind("resize", function() { x = 300; }); }); Note: x cannot be put outside the document.ready function because it uses jQuery. ...

Javascript link tracking script + Safari

Hi, I'm trying to make a link tracking script. It should work like Google Analytics only it should make posts to our own server. I'm using jQuery for this. The code i have written so far is the following: jQuery(document).ready(function() { var opts; jQuery.fn.trackAllLinks = function(settings) { settings = jQuery.extend({}, jQuery....

Popup using jQuery?

I'm trying to do a pretty simple thing, I believe. I need to popup a success confirmation dialog after a user clicks to add someone to his friends list. Simply there's an add link on the page with the url (mysite.com/add/friendname). I needed to make issue this request asynchronously so I used jQuery.ajax built-in function to send the re...

Use Asp.net to inject javascript

Hi Im using my asp.net code behind to register some startup script. The following code gets rendered to the browser. var rotator = new ImageRotator('rotateImg'); rotator.AddImage('DisplayThumbnailImage.aspx?FilePath=C:\Development\Projects\TouchSA\Trunk\WebSite\Gallery\photo_4.PNG&ThumbnailWidth=535&ThumbnailHeight=316'); rotator.Rota...

How can i trace changes made to the DOM by JavaScript?

Hi, I have a large website in development with a large amount of JS in different files. I have come across an issue where something is removing a class from the DOM. I can see it when I view source but not in Firebug. Normally I would place some alerts/console.log calls with the hasClass value but because I have no idea where to start ...

SVG via dynamic XML+XSL

This is a bit of a vague notion which I have been running over in my head, and which I am very curious if there is an elegant method of solving. Perhaps it should be taken as a thought experiment. Imagine you have an XML schema with a corresponding XSL transform, which renders the XML as SVG in the browser. The XSL generates SVG with ...

Pass IEnumerable List to javascript

I was wondering if I could pass a IEnumerable Collection into a Javascript method on the page load. So something like this... <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<MyAppMVC.Models.ViewModels.News.NewsIndexViewData>" %> <div id="container"> <%= String.Format("<script type='text/javascript'>testMethod({0...

How to find actual rendered values of elements set to 'auto' using JavaScript

Suppose I have the following html, and no CSS <div> here is some content in this div. it stretches it out <br />and down too! </div> Now I want to get the actual pixel width and height that the browser has rendered this div as. Can that be done with JS? Thank you. ...

What does ‘::’ (double colon) do in javascript?

The documentation of some JavaScript API shows the following snippets as example how to invoke some function: <button type="button" onClick="foo.DoIt(72930)">Click</button> <button type="button" onClick="foo.DoIt(42342::37438)">Click</button> :: is obviously used here to allow either one or two arguments to be passed to the function....

Use jquery to get value of field with dynamically generated name

I have a form with field names that are generated dynamically by server side code. I am attempting to allow JQuery to manipulate the value of these fields, but am running into trouble. The generated fields are paired using a unique ID number Example: A radio button named option_3030 Will have a amount_3030 field The number of dynam...

JavaScript: sorting collection, which is not an array

I have a collection of objects in JavaScript like this: Object collection = new Object(); collection[123] = new Item(); //another object collection[425] = new Item(); collection[2134] = new Item(); //etc. etc. //TODO: sort items I would like to sort this collection according to the properties of the Item objects in collection. Ther...

Why RegExp with global flag in Javascript give wrong results?

What is the problem with this regular expression when I use the global flag and the case insensitive flag? Query is a user generated input. The result should be [true, true]. var query = 'Foo B'; var re = new RegExp(query, 'gi'); var result = []; result.push(re.test('Foo Bar')); result.push(re.test('Foo Bar')); // result will be [true, ...

Menu hover state lost!

I like my menu to be interaction on :hover. So here is the code: $('#menu img').hover(function (){ $(this).removeClass(); $(this).addClass('menuon'); return false; }, function(){ $(this).removeClass(); $(this).addClass('menuoff'); return false; }); This code works fine, but the side effect is when the menuon s...

jQuery selectors stored as properties in a namespace

I am working on refactoring a JavaScript namespace for a site. The namespace leverages jQuery for selectors and events. Here is an example. MyNamespace = { eventElements : { headerSectionA : $("h1.section-a"); headerSectionB : $("h1.section-b"); } sectionA : function() { // do stuff for section A here...

Regex to detect Javascript In a string

Hello I am trying to detect JavaScript in my querystrings value. I have the following c# code private bool checkForXSS(string value) { Regex regex = new Regex(@"/((\%3C)|<)[^\n]+((\%3E)|>)/I"); if (regex.Match(value).Success) return true; return false; } This works for detecting <script></sc...

How to get a hover/mouseover effect to stay selected?

Hi! I'm very much a beginner when it comes to Javascript and would appreciate any help you can give! I'm creating a feature box on my home page where three headlines will share one picture spot. I've found a script that changes the image when the headlines are rolled over, but it's hard to tell when the page opens that the first headline...

How do I shift an array of items up by 4 places in Javascript

Hi, How do I shift an array of items up by 4 places in Javascript? I have the following string array: var array1 = ["t0","t1","t2","t3","t4","t5"]; I need a function convert "array1" to result in: // Note how "t0" moves to the fourth position for example var array2 = ["t3","t4","t5","t0","t1","t2"]; Thanks in advance. ...

Reading data from JavaScript updated html

Is it possible to read the realtime updated quotes in this website through actionscript3, without having to reload the page all the time, which would be network-heavy. In other words, is it possible to stream the quote-data directly into actionscript3 or eventually PHP from javascript? If not does anyone have any suggestion to how to g...