javascript

How do I call functions of an object inside the same object?

I have the following Javascript code add_num = { f: function(html, num) { alert(this.page); }, page : function() { return parseInt(this.gup('page')); }, gup : function(name) { name = name.replace(/[\[]/,'\\\[').replace(/[\]]/,'\\\]'); var regex = new RegExp('[\\?&]'+name+'=([^&#]*)'); var results = regex....

How to have function recall private variable between invocations

Here's an easy one straight from the text book I can't seem to find. I have a javascript function. I want it to contain a private variable which remembers its value between invocations. Can someone jog my memory please. ...

jQuery: resizing element cuts off parent's background

Hi, I've been trying to recreate an effect from this tutorial: http://jqueryfordesigners.com/jquery-look-tim-van-damme/ Unfortunately, I want a background image underneath and because of the resize going on in JavaScript, it gets resized and cut off as well, like so: http://dev.gentlecode.net/dotme/index-sample.html - you can view sourc...

When is a cookie available?

Hi i have a web application where i plant a cookie on my page. Then the user goes to another page, and from that page calls my page from a script, like this: <script type="text/javascript" src="http://domain.com/page.aspx?id=6" ></script> But i cant access the cookie when it calls my page, why not? and how to work around it? Please ...

Downloading javascript Without Blocking

The context: My question relates to improving web-page loading performance, and in particular the effect that javascript has on page-loading (resources/elements below the script are blocked from downloading/rendering). This problem is usually avoided/mitigated by placing the scripts at the bottom (eg, just before the tag). The code ...

Javascript get XPath of a node

Is there anyway to return an XPath string of a DOM element in Javascript? ...

stop javascript execution

When I run javascript script file in windows command line environment, and there is a free text coming after my code. How can I stop javascript interpreter to run into it? For example: var fso = new ActiveXObject("Scripting.FileSystemObject"); delete fso; exit(); // some kind of WORKING exit command Hungry lazy frog ate a big brown fox....

Binding multiple events in jQuery

I have a custom jQuery plugin which binds a change event to a form element, in this case some input elements. The change event is used to indicate to some other components that a change has taken place. This works as it should. However, I've come across the need to bind an additional change event to the same input elements -- so that a...

Nested function inside literal Object...

Hello guys, if in a literal object i try to reference a function using "this" inside a nested property/function, this don't work. Why? A nested property have it's own scope? For example, i want to call f1 from inside d.f2: var object = { a: "Var a", b: "Var b", c: "Var c", f1: function() { alert("This is f1"); }, ...

Javascript crazy idea finding a node

I had a crazy (but so crazy that it just might work) idea where every element on a page is created in javascript but given an ID which is a hash of its path in the DOM. So instead of searching through the DOM to find an element, you hash the path and then getElementById() with that hash. Problem with this is getting the path might be...

Both tab & hover triggered popups problem

I am trying to display divs when hovering over thumb-nails and/or both when tabbing onto them. If I stick to my mouse, the popups seem to work OK - if I start with a tab press I can show the popops also (foward only - no shift + tab yet). Any help getting them to play well together? // Note: the below is being run from an onmouseover ...

Google Chrome showing javascript security error

I need help resolving this Google Chrome Error..."Uncaught Error: SECURITY_ERR: DOM Exception 18" Here is the code. //Get Cookie function get_cookie (cookie_name) { var results = document.cookie.match ( '(^|;) ?' + cookie_name + '=([^;]*)(;|$)' ); if (results) return ( unescape ( results[2] ) ); else return null; };...

Image Gallery with JQuery Lightbox

Hi there, I've used the JQuery lightbox on a couple of websites, by having a gallery of thumbnails and the thumbnails as links to the bigger photos. My question is, using lightbox - can I make it so that I have a thumbnail image that when clicked takes you to a folder with a few pictures to cycle through, rather than just linking to on...

How to merge if/else statements in JS?

Hello! I'm wondering how to merge these JS if/else statements correctly? if (window.addEventListener) { window.addEventListener('dosomething', foo, false); } else { document.addEventListener('dosomething', foo, false); } if (window.attachEvent) { window.attachEvent('dosomething', foo); } else { document.attachEvent('dosomething', foo);...

How to check whether the input text field contains only white spaces ?

What is the easiest way to check in Javascript whether the input text field is empty (contains nothing or white spaces only)? ...

Reference Error for property of Javascript Object

I have built an object in Javascript on the Google Apps Script engine and every time I run my script I get a reference error saying uName is not defined. Here is the relivant code: function DataSet() { this.uName = ""; this.dField = ""; this.qUrl = "http://api.bfbcs.com/api/pc?players="+uName+"&amp;fields="+dFeilds; this.data =...

Web page for IPhone - Large fonts instead of scrolling?

I'm planning the layout of my web page, which should also be usable on the IPhone. I don't really have much experience with the IPhone yet - I just installed the IPhone Simulator on my Mac. The page's contents are flexible, so I think it would be better to use this flexibility to avoid that the user has to scroll around the entire page....

Javascript Noob Question. Need Help With Simple Script

Hi everyone, I am new to JavaScript (only a couple of days of reading a book) and I am stuck on this code snippet. I have looked at it over and over again but cannot seem to figure out why it is not working. I am sure it is something really simple that I have just looked over but I really just need a fresh pair of eyes to look at this....

Jquery AJAX and figuring out how NOT to nest callbacks for multiple reloads.

I have a site with a few containers that need to load content dynamically via AJAX. Most of the links inside of the containers actually load new data in that same container. I.E: $("#navmenu_item1").click(function() { $("#navmenu").load(blah); }); When I click on a link, lets say "logout," and the menu reloads with the updated logi...

javascript. is it posible for one member of an object to access another member of that object without explicit reference to the object itself?

For example: var myObj={ myValue="hola", asMember=function(){ alert( this.myValue ); } }; myObj.asMember(); // will work fine var asGlobal=myObj.asMember; // global alias for that member function asGlobal(); // won't work in javascript (will work in AS3, but i need js now) So the question is, can I rewrite asMember so that i...