javascript

JS: Entering a TRUE value into a prompt box and having it alert its variable.

I'm wondering if it's possible to enter a value of a variable into a prompt box have it return to me in an alert of its original variable. Say: var myGoal = "answer"; If I enter "answer" into a prompt, what would a good method be of taking my value of "answer" ,searching, and having it return myGoal in an alert? ...

window.scrollto javascript call to uiwebview misbehaving

i have several uiwebviews with a considerable amount of text. when making a window.scrollto (as well as a window.scroll) javascript call to the webviews, they scroll to an incorrect location. e.g. i want to scroll to 12000 but the webview will scroll to 10149 every time instead. while another one will scroll to 10250. yet another one, wh...

jQuery event when select option

What's the event to bind for when a select form is selected? I have something like this: <select id='list'> <option value='1'>Option A</option> <option value='2'>Option B</option> <option value='3'>Option C</option> </select> When Option B is selected, I want some function to run. So what do I bind, $("#list").bind("?", function (...

How to set up a "settimeout" properly for a jQuery function?

Hello everybody, I hope I can get some help. I'm new to Jquery and JavaScript and I got stuck with a "setTimeout" function. I'm working on my navigation bar and basically I need a div(sub menu) to fade in when "click" on an anchor tag, fade it out if you move the mouse to a different navigation link and hide it all together if the mouse ...

Static variables in JavaScript

How can I create static variables in Javascript? ...

How to automatically resize popup window or modal dialog for content change

I have an iframe that can appear in a jQuery modal dialog, a popup window, or just as part of a page. The height of the content of this iframe can change as elements appear and disappear, and I need the containing iframe, along with the modal dialog or popup window where applicable, to change height as necessary to be 'just right' for t...

Layering intersecting elements with jQuery

I have a page with draggable/droppable elements that once dropped need to calculate their left position and width in regards to other draggables that they may be touching. This isn't too hard in and of itself, but where I'm really having trouble is getting them to fill in empty space. How do I get the draggables to fill in the empty spa...

Sort Unordered List with Javascript

Hi, I have been looking at the stackoverflow thread: http://stackoverflow.com/questions/1134976/jquery-sort-list-items-alphabetically but for my scenario, I have the hierachy: <ul><li><a href="http://www.google.com.au"&gt;NAME_TO_SORT_ON&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt; Based on this set-up, how can I modify the solution from thread...

Parent Div's mouse out function is called on mouseover of child element

I have the below HTML in my page <div id='divContainer1' onmouseover=ShowEditDiv(1) onmouseout=HideEditDiv(1) class='divClcContainer'> <div id='divSlNo1'>1</div> <div id='divItem1'>This is content</div> <div id='divEditLink1'></div> </div> <div id='divContainer2' onmouseover=ShowEditDiv(2) onmouseo...

How to refresh parent page from child page in asp.net 2.0

Hi all, I have a page showing all products in a gridview. I have a link in the page clicking on it opens a modal window. In the modal window there is a form to enter product and save. When I fill the form and save product I need to make the parent page to be refreshed so that the new product is listed in the gridview and a message will ...

Prepend .css file - Firefox vs IE

I found out IE has different behavior vs Firefox when I use this $('head').prepend(''); That basically just to add the theme-2.css on top within HEAD tag (for theme purpose). I do that because I don't want it to load yet because I use the csspreload http://www.filamentgroup.com/lab/update%5Fautomatically%5Fpreload%5Fimages%5Ffrom%5Fcss...

Module pattern vs. instance of an anonymous constructor

So there's this so-called module pattern for creating singletons with private members: var foo = (function () { var _foo = 'private!'; return { foo: function () { console.log(_foo); }, bar: 'public!' } })(); There's also this method that I found on my own, but haven't seen anything written about: var foo =...

Changing context of a function in javascript

I'm trying to understand why in javascript, you might want to change the context of a function. I'm looking for a real world example or something which will help me understand how / why this technique is used and what its significance is. The technique is illustrated using this example (from http://ejohn.org/apps/learn/#25) var object...

Javascript position two elements on top of each other

I have two divs one above the other. The second on is absolutely positioned below it (an absolute div inside a relative div). I want to move the second div on top of the other div, so it appears in the middle. The procedure for this is to set the style.top of DIV2 to be the same as DIV1, this should in theory position it on top of it. ...

how to display a date as 2/25/2007 format in javascript, if i have date object

how to display a date as 2/25/2007 format in javascript, if i have date object ...

create imagemap with Javascript

Dear all, Is there a way to create an imagemap on an image when the image is created in Javascript? So image is created this way: var img = new Image(); then set all properties. But how do I now create an imagemap on this image? Regards, Tony UPDATE Here's my code to create image: function createimg() { var img = new...

What percentage of followed hyperlinks might have their "onclick" JavaScript ignored?

As far as I know all popular web browsers execute the onclick attribute of an anchor link first, then follow the path specified by the href attribute. The problem here is that the onclick attribute only gets called when clicking with the left mousebutton (without pressing ctrl or shift for a new tab or window) or when pressing enter on ...

how to check if the value exists in lonListBox and update or insert the value

i want to check if the TextBox3 which contains the id of a google marker exists in the lonListBox2 and if does update the value or if not, insert the value in the lonListBox2. now as it is the function makes no changes in the form , maybe the tagName doesn't exist. here is the javascript function <script type="text/javascript"> ...

Force a page refresh using Javascript in Firefox

Hi All, I have a simple request to refresh a page using a Javascript code below: function tb_closeRefresh() { window.location.reload(true); } This works fine in IE but Firefox just gets the cached version and needs the user to press F5 to get the latest version of the page. I have added the meta tag: <meta http-equiv="Pragma" c...

JavaScript - controlling the insertion point for document.write

I would like to create a page that runs a 3rd party script that includes document.write after the DOM was already fully loaded. My page is not XHTML. My problem is that the document.write is overwriting my own page. (which is what it does once the DOM was loaded). I tried overriding the document.write function (in a way similiar to htt...