javascript

Any good resources for learning intermediate javascript?

hello, I'm very confused .. I have just finished studying Javascript , and when I wanted to learn more practical uses of js like making a sliding menu or drag and drop actions on online tutorial sites like nettuts, or pixel2life, I find very complicated examples that are not suitable for my level. They treat me as a pro, they use in the...

Using JavaScript, how can I prefetch another web page on my site?

I have Large.html, which is a web page that has a lot of images and javascript on it which takes a long time to load. From other pages (a.html, b.html) how can I use JavaScript to prefetch Large.html (and all of the elements on the page) so that I can get the page cached in the users browser to help speed up page loading. Would I need ...

creating an element and setting its attribute with jQuery

Hello all, I'm trying to create an <ol> element with jQuery and set its class and id attributes. Is there any way to do this all at once? None of my ideas have worked so far, I'm still very new to jQuery... ...

Javascript Regex Browser Inconsistancy?

I have a regex that I am using in an asp.net RegularExpressionValidator to check a TextField. ^(?=.*[a-z])(?=.*\d)(?=.*[A-Z]).{8,}$ The example string I have stumbled on is 'RedCoal1' Firefox = Matched IE8 = Matched Chrome = Matched IE7 = DOES NOT MATCH WHY!!!! ...

extjs: How to fill combo box with tree node's immediate children?

Hi, I have a tree and a combo box. I need to get the immediate children of node 1 and place them in the combo box. When a node is selected from the combo box list, the tree should display only that node and its children. Basically, the combo box serves as a filter to show only a specific node. All the nodes except from the selecte...

How can I return AJAX response text?

For the sake of better organized code, instead of putting a callback function within my req.onreadystatechange handler, I'd like to simply return the data. In the following javascript, the "raw_data" var is undefined because parse_data() function is called before the ajax response. function dostuff(){ var raw_data = ajax_fetch_data(...

post increment vs pre increment - Javascript Optimization

I was browsing Google Code when I chanced upon this project called JSpeed - optimization for Javascript. I noticed one of the optimization was to change i++ to ++i in for loop statements. Before Optimization for (i=0;i<1;i++) {} for (var i = 0, j = 0; i < 1000000; i++, j++) { if (i == 4) { var tmp = i / 2; } if (...

Javascript/Canvas/Images scaling problem in Firefox

I have a problem with the context2d's drawImage function. Whenever I scale an image, it gets a dark border of one pixel, which is kind of ugly. That does only happen in Firefox, not in Opera or Webkit. Is this an antialiasing problem? For hours I studied the examples and available documentation without getting rid of it... I couldn't ye...

How to prevent View Source of page using Javascript?

How to prevent to download the source code of page using File > Save as? ...

in a javascript object literal, how to reference a function that has the same level or upper level?

as the following code, my question is: in testFunction, how can i call function remove? in remove how can i call testFunction? in remove, how can i call add? great thanks var stringhelper={ testFunction:function(){}, //deal with text such as: //"alignleft red bold header2" classValue:{ //test whether classValue has className in it ...

how to handle IE select onchange and ajax requests

Let's say I attach a javascript "change" event handler to a select element, something that dispatches an ajax request to load some stuff from the server. This is fine in Firefox. However, in IE, the change event will fire every time you scroll rapidly through the combo box options using a mouse wheel. This is troublesome because it spam...

Google SEO and hidden elements

Will google ignore words that are inside the elements that are set to "display: none" in css? Example: <div id="under_meny" style="display:none;">About Us | Contact Us</div> It looks maybe a bit strange that I want to hide a menu like that, but there is a submenu. And will the user to activate it. But I do not want it to go beyond SE...

Javascript Tricks and Hacks

Hi, I would like to gather some ideas how you can implement Javascript in a site that don't allow you to put javascript. Site's I'm talking about are community sites like MySpace, That only allows you to put HTMLs. some of their implementation I've seen is something like this. <img src="imagesource" onerror="javascript: find head and ...

Setting boundary limits for a draggable object...

I have two elements: 1) a parent of fixed height, overflow:hidden 2) its child, of larger fixed height. <style type="text/css"> .myList {list-style:none; margin:0px; padding:1px;} .myList li{ height:50px; margin:4px; padding:2px;} .dragPanel {height:230px; border:solid; overflow:hidden;} </style> <div class="dragPanel">...

Restricting text box inputs to a given regexp using jQuery

Consider the following text box: <input type="text" name="quantity" id="quantity_field" /> Using jQuery I want to restrict the set of valid inputs into quantity_field by the following regexp: <script> var quantityRegexp = "^(0|[1-9]+[0-9]*)$"; </script> More specifically I want to make the browser discard any characters entered ...

Why does my COMET control throw a javascript error when IE8 closes?

I've written a COMET/Reverse Ajax table control in ASP.NET. The javascript part uses jQuery (1.3.2). It seems to be working OK, apart from when closing the browser in IE (8). In this case it throws a "Microsoft JScript runtime error: Object doesn't support this property or method". It's only when IE is closed that I get the error. Firefo...

How to check if cards in hand match cards on table?

There are 8 cards on the table, with four faces visible and four hidden. Click on a card to turn it and if there's a pip-match or suit-match, show sparks around the associated cards. Problem is, I'm either doing something wrong logic-wise, or .concat() is not working. Because some sparks show and some do not. The whole game could proba...

How can I open a new browser tab from within JavaScript?

How do I write a JavaScript function that opens a new browser tab at a specified URL? I know how to do this in In HTML using a link with target="_blank", but in my case I need to do it from within the JS function. Thanks ...

jquery datepicker getMonth() weirdness

Hi all, jquery datepicker is a great fun but I am facing a weird error. I am trying to disable some days, ie. 28 October 2009 but 28 November gets disabled on the calendar! Any idea what I am doing wrong here? The disabledDays array variable is a script registered on the server as the closing dates come from database. <script type="text...

Change values in form submitted and the JQuery serialize function

Hello all, Please look at the following code. When the form gets submitted, is it actually submitting the values I have entered i.e. val(50) or at the point it serialzies does it just get data from the form on the actual html page? // stop all forms from submitting and submit the real (hidden) form#order $('form:not(#order)').submit(fu...