javascript

Best practice for warning the user they will lose data.

I have a site which uses a lot of JavaScript (mainly jQuery) and I need a nice global way to let the user know that they will lose unsaved changes when they navigate away from a particular page. At the moment I have an onchange event placed on the inputs and wrap my main navigation in a function which will display the warning when click...

How my select list become uneditable?

Hi everybody, I am coding some sort of booking system - calendar. One of the features is also a (js) pop up window with detailed information about event - user can either view them or edit. Now my problem - I have put there a HTML select control (dropdown box), quite simple - 5 options. But somehow, and I have no ide why, this select i...

Firefox and Safari stylesheet loading time, firing JavaScript event when loaded

We have some JavaScript code that resizes <div/> elements (adjusts height/width/padding/margin etc.) based on the dimensions of a parent <div/> element, specifically the height and width of the parent we use in the calculation. The parent div height and width is defined in a external CSS file, and <link> is used to include the stylesheet...

how to Custom build a javascript API based on Jquery and some questions about the syntax used in Jquery.

Hi all, I come here with quite a bunch of questions so lets start: I want to know some things about the syntax used to make jquery as I wish to learn from it an use it for my self. Question 1: The starting of the jQuery library (function( window, undefined ) { // Define a local copy of jQuery var jQuery = function( selector, conte...

How to stay in the same location after an alert?

I have an alert box in javascript which is prompted by clicking a link down the page. When the alert box pops up, and the user presses ok, the user is redirected to the top of the page. How do i make it so the page stays where the user prompted the alert box? Thanks!! ...

Mootools doesn't fire the "onChange" event for Selects in IE7

Hi, i'm working with mootools 1.2.4 and i have a select with an event "change" that works fine in Firefox but when i try to test it in iexplorer 7 it gives me an error saying that the select doesn't have that property or method: my code is as simple as: $('zone').addEvent("change",function(E){ alert("change"); }); i've ...

Adding JS To Codeigniter Links - Simple OnClick

I am trying to write a simple Javascript snippet into a Codeigniter link. I am using the link to delete posts where required in my dashboard. I dont know anything about JS although am trying to learn it. Code $js = 'onClick = "alert("Are you sure")"'; $this->table->set_heading('Date', 'Title', 'Delete', 'Update'); foreach($records ...

Unbind mouseup?

I am trying to unbind the mouseup event from an element. I have tried the following but none are working. $('#myElm').unbind('mouseup'); $('#myElm').unbind('onmouseup'); $('#myElm').unbind('click'); How do you unbind an event assigned using $('#myElm').mouseup(function({...}); ??? Edit: Adding full code cacheBgArea.mouseup(functio...

sIFR: Change Drop Shadow Colour on Mouseover?

Using sIFR version 3, i have added a drop shadow to some link text, is it possible to change the shadow colour on mouseover, basically on a:hover ...

How can I prevent a form reset from clearing my <input type="text"> element?

If I put a form control on the page with a value already set, triggering the containing form's reset functionality will return the value to the original value at the time when the page was loaded. However, if I create a form control using javascript, and append it to the DOM, the form control will be erased and made blank when the form ...

GEOWEBCACHE pass time parameter into string request.

I'm using geowebcache to return the data to OpenLayers, now I need to pass the time variable in the http request and i don't know how, so when i make the request with the time that can vary the same is sent with the request to the geowebserver and passed to the service if no cached... ...

Why not vanilla Jquery for mobile? i.e. in contrasts to mobile-specific jquery-based libraries (jqtouch/sencha)?

Hi all, This may seem like a basic/stupid/obviously-answered question, but I wanted to check: why use a mobile-oriented javascript library (e.g. jqtouch) instead of straight jquery? The context: We're looking at enriching the mobile-view of our web-app. I tried the various jqtouch demos on my android 2.1 (Motorola droid). Many of the...

how to style incrementally with javascript?

Hi all, So i am using jQuery and i have a rather large table for what i want to do (> 100 rows). For every row, i'd like to do quite a bit of work on it, my question is if i have $('#tableid>tr').each(function(i){some code here}); How do i stop processing when i hit multiples of 5 and just put the effects out on the browser first so...

How do I pass the value of a variable to an specific page element with solely javascript?

Let's say I have: var url="http://www.google.html"; how do I put the url variable value as the href value of an specific anchor tag in the page? I know about str.link() but how I can use that with an specific element? and can I use link*( to build anchors of images? That didn't seem to work for me. Thanks for the help ...

Pass the value of a SELECT to a Javascript function via the onchange event?

I have a HTML page that contains a search box containing a number of textboxes. The first part of the search box is a SELECT dropdown list that contains a variety of report types. Each report type requires 1 or more of textboxes to be filled in to filter the query results. My goal is hide the textboxes that are not required by the cur...

How to create a jQuery element cache mechanism?

I think I wrote a simple DOM cache mechanism to be more efficient, avoiding multiple $('blah') calls, e.g.: if ($('foo').length) { $('foo').bar(); } So I created a DomCache child object under my project main object: MyLib.DomCache = {}; When I need a jQuery object of an element, I look in the DomCache and if I found it I use it...

browser event for window.focus()

Hi all, Is there a way that when i click on my browser, and give it focus, to run a method once? And then when the browser loses focus and then get focus back to again run that method only once, again. Thanks, rod. ...

SQLITE + CHROME/SAFARI: "not authorized" ERROR

I am trying to do a bulk transaction using SQLITE on CHROME (and SAFARI). I'm doing this with javascript so this is what I have: ============================================================= query = "BEGIN TRANSACTION; " query += "INSERT INTO schools (name) VALUES('School 1');" query += "COMMIT TRANSACTION;" db.executeSql(query); ...

Get results from php script via jquery load() functon before php script finishes

I have the following situation: jquery: $(function(){ $('input[type="button"]').click(function(){ $('#result').load('script.php'); }); }); script.php: <?php echo "1"; sleep(2); echo "2"; sleep(2); echo "3"; ?> Currently the jquery load function will wait for the php script to finish and the...

Jquery, CSS: How do I resize a set of fixed elements to dynamically fill the remaining height of the browser window?

Basically, I have a set of fixed elements that start 180px from the top of the page. They're all stacked, and I use another set of functions to hide/unhide them accordingly to emulate tabs. They all belong to the same class 'editor_view'. I want each of them to terminate at the bottom of the page. What would the code for this look li...