javascript

Non-static private variables in javascript

I'm setting up my javascript objects like the following Object1 = function() { var privateMember = "private value" return { publicMember: "public value" setPrivateMember: function(value) { privateMember = value; } } }(); Now if I use prototypal inheritance to create new objects Object2.prototype = Object1 ...

What's a valid left-hand-side expression in JavaScript grammar?

Okay, we all know what the valid left-hand-side expressions are. Kind of.* But, looking at the definition from the ECMA-Script standard, I'm very confused: LeftHandSideExpression : NewExpression CallExpression Is that just an error in the definition, or am I getting something wrong here? I mean, doesn't that actually mean tha...

Cross domain javascript form filling, reverse proxy

Hi, I need a javascript form filler that can bypass the 'same origin policy' most modern browsers implement. I made a script that opens the desired website/form in a new browser. With the handler, returned by the window.open method, I want to retrieve the inputs with theWindowHandler.document.getElementById('inputx') and fill them (acc...

How to use javascript namespaces correctly in a View / PartialView

i've been playing with MVC for a while now, but since the project i'm on is starting to get wind in its sails more and more people are added to it. Since i'm in charge of hacking around to find out some "best practice", i'm especially wary about the possible misuses of javascript and would like to find out what would be the best way to h...

Changing the namespace in ASP.NET .ASMX webservices?

I'm trying to call an ASP.NET .asmx webservice, from javascript, using other than the default namespace that Visual Studio uses when it creates it. When I use the Visual Studio wizard to create a webservice named Hello, in the folder WebServices, it creates this: namespace MyWebSite.WebServices { [WebService(Namespace = "http://tem...

Injecting javascript and HTML using AJAX

Heya all, First of all I would like to say that while this is the first time i post here these boards have helped me much. With that said, I have got a strange issue regarding AJAX and scripts. You see, in my web application i used custome JS context menus. Now each of them menus is implemented with specific features depending on the ob...

How to check if a string is a valid JSON string in JavaScript without using Try/Catch

Something like: var jsonString = '{ "Id": 1, "Name": "Coke" }'; //should be true IsJsonString(jsonString); //should be false IsJsonString("foo"); IsJsonString("<div>foo</div>") EDIT: The solution should not contain try/catch. Some of us turn on "break on all errors" and they don't like the debugger breaking on those invalid Json str...

puzzle: value in clousure is changed.

I use http://tile.cloudmade.com/wml/latest/web-maps-lite.js to geocode. There is a address array containing around 20 addresess addresses[n] = {where:where,who:who,contact:contact,note:note,type:type}; Then I loop the array to geocode for (var i = 0; i < addresses.length; i++) { geocoder2.getLocations(addresses[i].where, functio...

jquery dropdownlist, onchange reload page using Get request with ID of dropdown value

When someone selects an item in a dropdown, I want to reload the current page with the value of the ID in the selected item in the querystring like: http://www.example.com/mypage?id=234 How can I do this? ...

Does javascript have the interface type (such as Java interface)?

I'm learning how to make OOP with javascript, and I wonder if it have the interface (such as Java interface) concept? So I would be able to create a listener... ...

js variable scope question

how do i make data overwrite results variable ? var ajax = { get : { venues : function(search){ var results = "@"; $.getJSON("http://x.com/some.php?term="+search+"&amp;callback=?",function(data){ results = data; }); return results; } } }; ...

press tab to go to selectbox

i have a textbox follow by a selectbox, when i press "tab" on textbox, it doesnt go to selectbox. how to make it go to selectbox? is the solution required to use javascript? is there any workaround without using javascript? editted: <html> <input type="text" tabindex="1" /> <select tabindex="2" > <option value="volvo">Volvo</option> ...

Manipulate href of anchor based on class in Prototype

I'm trying to manipulate some anchors after the document is loaded to alter their href attribute using Prototype. Based on the class of an anchor, its href has to be rewritten to be used by a tracking software. I hacked some things together but can't quite figure out why it doesn't work. It always returns undefined, not matter what I se...

can't find what is wrong in the syntax

Hi, I have the follow code: onclick=" <?php echo 'postwith(\''.$_SERVER['PHP_SELF'].'\',{export:\'export\',date:\''.$_POST['date'].'\'})'; ?>" while postwith is a function. in ie i have an error: Expected identifier, string or number in firefox it's ok and the link is: postwith('/page/page.php',{export:'export',date:'Yesterday'}) ...

Jquery .load issue when dealing with Iframes?

I use successfully the following code to load asynchronously some content into a web page: jQuery.noConflict(); jQuery("#boxasync").load("box.php", "", function(responseText, textStatus, XMLHttpRequest) { if(textStatus == 'error') { jQuery('#boxasync').html('There was an error mak...

MVC, ascx and Javascript best practice(s) - how to create self-containing controls? NerdDinner does it wrong.

Hi, The question is how to create controls/partial views/edittemplates (ascx files) in ASP.Net MVC2 so that they are "self-containing". Self-containing means here that if some Javascript code should be applied on the control, that's not included in the page (aspx), but in the control itself. Specific example: NerdDinner's DateTime.ascx....

Appending tr to tbody using YUI

I know this can be done easily using jQuery but haven't been able to find out how to accomplish it with YUI 2. I am submitting a form via AJAX and in the callback, on success, I want to add the information that was inserted into the existing table in the DOM. This is what I am trying with no success: var callback = { success: func...

How to find ClientId of a control in prototype javascript

I have HTML control in my page .Could you please tell me how to get client Id using prototype javascript. ...

How to run a function when iframe src changes?

How can i run a function when the src of an iframe is changed? The iframe displays a site that is not on my server... When the user clicks on or presses a button inside the iframe, i'd like to perform a function to test whether the src has changed... ...

Jquery - changing background image - throws weird error

Hi, I have 4 list items in my HTML and there is image and a text in the Item. What I am trying to do is when someone clicks on the list item, I want to pull the text out of it and use it to form an image url and assign it to an element's background. But this simple stuff is not working and firefox is throwing a warning without changing ...