javascript

Unable to toggle div on top.document

I have an iframe that returns data to the top.document window just fine by using: $("#someDiv", top.document).html(data); The above works fine. Now I want to be able to hide a div on the top document and I try: $("#someDiv", top.document).toggle("slow"); It is not working... any ideas? ...

webex interferes with web application

I received a complaint about buttons disappearing and odd formatting of a web application that I support. Upon troubleshooting, it seemed that the only thing new about the environment (which was previously working fine) was the installation of webex on the client machine. Uninstalling webex resolved the issue. Please mind that webex...

Why does a $ in the replacement string passed to the replace() function break some of the time?

I have a variable that I'm using to build a JavaScript function call, and JavaScript's .replace() to surround the line of text with a span and onclick event. The .replace() portion looks like this: code.replace(/(\d{4}\s+)?(LOCAL|PARAMETER|GLOBAL)\s+USING\s+([\S]+)/g, "<span class=\"natprint_popup\" onclick=\"getNaturalCode('" ...

Javascript: Does modifying scrollTop/scrollLeft trigger browser reflow?

I'm wondering if animating the scrollbars with Javascript triggers browser reflow. Any difference across different browser implementations? window.pageXOffset & window.pageYOffset document.documentElement.scrollLeft & document.documentElement.scrollTop document.body.scrollLeft & document.body.scrollTop Thanks! ...

Javascript: How to lock AJAX functions from overlapping?

So here's my problem: I've got one function that runs every 15 seconds. It checks to see if new comments have been added to a page. I've got a form that submits a new comment once the submit button is pressed, then displays the new comment on the page. In the process of adding a new comment, the "checkEvery15Seconds" function is query...

Is there an easy way to create dynamic variables with Javascript?

I've built a data-driven google map with different icons that get assigned to the map depending on the type of item located. So if I have 5 types of landmark, and each gets a different icon (store, library, hospital, etc.)-- what I'd like to do is generate the google icon objects dynamically. I was thinking something like this: types = ...

Getting reference to the JavaScript Function object behind an operator

Here is a lisp procedure that simply adds 'a' to the absolute value of 'b': (define (a-plus-abs-b a b) ((if (> b 0) + -) a b)) I think this is beautiful, and I am trying to find the best way of writing this in JavaScript. But my JavaScript code is not beautiful: var plus = function(a,b) { return a + b; }; var minus = function(...

jQuery sort unordered list alphabetically and numerically based on inner element value(s)

Code as reference: http://jsbin.com/aboca3/2/edit In this example above (thank you SLaks) I am truncating long unordered lists and providing a toggle link to view the entire thing. The issue, from a usability standpoint, is that as a full list, it is best sorted alphabetically, which will be the default sort order (the source order). ...

Making a Method Globally Accessible in Javascript

given i have the following block of code (function(){ var mb = { abc:function(){ //do something }, xyz:function(width, height, site){ //do something } }; })(); how do i make the method mb.abc accessible from the page, but not mb.xyz? ...

JavaScript: GIF file loses animation

I am trying to set a hidden layer (containing animated GIFs) visible. Initially, the layer is hidden using display: none; However, when I try to show the layer using javascript: document.getElementById('loading_layer').style.display = 'block'; the layer is displayed, but the images inside it are no longer animated. What could be th...

multiply in javascript can't get correct answer.

Possible Duplicates: Why 81.66 * 15 = 1224.8999999 in Javascript (or Perl) and not 1224.9 ? Is JavaScripts math broken? var t1 = 5000; var t2 = 0.07; alert(t1 * t2); Here is very simple code that return incorrect result; I predict the result is 350 but the result is 350.00000000000005 How can I get correct result? and ...

I like this trick...but is it safe in JavaScript

The main issue I'm thinking about is whether assigning a variable in an if statement is safe and reliable across different browsers. If it is safe, I'd like to use it. Here it reads the querystring and if the querystring variable SN is either Twitter or Facebook then it enters the if and you can use the variable, if the querystring var...

How to encrypt data in javascript and decrypt in php?

Is there any javascript function that can encrypt data: For example i want to use encrypted data in my URL passed by ajax GET request, http://sample.com/mypage/TDjsavbuydksabjcbhgy where TDjsavbuydksabjcbhgy an encrypted data equivalent to 12345. Now i want to retrieve that data in PHP by decrypting it, so that i can use the 12345. I...

First parameter to event handler

If I have some event handlers registered inline with my markup (deprecated, I know) like span id="..." onclick="foo(p1,p2,p3)" how can I access the "event" object in the event handler function foo? Changing the above to span id="..." onclick="foo(event,p1,p2,p3)" and then using it in "foo" like function foo(e,p1,p2,p3) { if ...

Scrolling with a styled unordered list (select box replacement)

My company had a website we're working on redone by a designer. It looks much better, but I've hit a snag implementing their design in HTML+CSS. They have a heavily styled <select> box, so much so that I couldn't recreate it with pure CSS. I found a solution that uses Javascript to replace the <select> box with a <ul>. This works almost ...

How can I set default today date using datepicker with jQuery?

I am using the jQuery datepicker(http://keith-wood.name/datepick.html) and I would like to set today's date on the calendar to a date of my choosing that never changes rather than take the system date as today's date. How can I set that up? ...

JavaScript and JSON array

I am trying to understand how a single and multidimensional javascript array would appear in JSON. Can anyone help me with an example for each? ...

Calling multiple javascript functions on a button click.....

How to call multiple functions on button click event? Here is my button, <asp:LinkButton ID="LbSearch" runat="server" CssClass="regular" onclick="LbSearch_Click" OnClientClick="return validateView();ShowDiv1();"> But my ShowDiv1 Doesnt get called.... My javascript functions, function ShowDiv1()...

Javascript and PHP to generate "live" print preview

I want to be able to enter data and use Javascript onChange/onBlur/etc to render a "live" print preview; with page breaks. The ultimate goal is to have a PDF file that can be saved/emailed/etc that will be identical to the "preview". The data is to be stored in a MySQL database, I'm figuring AJAX to write it while entry. Has anyone hear...

back button in IE7 on window.open?

I have a window that is created via window.open. When the window is created, we turn off the address bar (location=no). In IE6 this left the forward and back buttons active. The MSDN actually notes that this behaviour has changed for IE7 (http://msdn.microsoft.com/en-us/library/ms536651(VS.85).aspx ). The Back, Forward, and Stop comm...