javascript

How to use JSON to re-build the Javascript Object?

I have an object like this: var someObj = Class.create ({ initialize: function(objName){ this.objName = objName; } }); I can use o = new someObj("objName"); to make an obj. I can use Object.toJSON(o) to change the o to become a JSON String, but I want the JSON String convert back to someObj, so, I use eval() to pass the...

getting client id of a control from variable

Hi, I want the client id of an asp.net textbox control(txtTest) in javascript.But the problem here is the control id comes from a variable as shown below var testName = 'txtTest'; var testCntrl = document.getElementById('<%=' + testName + '.ClientID %>'); But its throwing CS1012: Too many characters in character literal Can ...

Mysterious postback issues with javascript (asp.net)

I show a modalpopupextender using javascript, and when I click its save button, it saves the things I have input in, and (as its a button) postsback automatically so the page refreshes. However when it refreshes, I get an error because it says the checkbox control I define on my aspx page is null. One of the first things I do when the ...

JavaScript / Rhino: Can I use a regular expression in an E4X query to select certain nodes only?

Hi! I'm working on Rhino (Mirth), and I've got to process / parse an XML with the following structure: <root> <row> <foo-1 /> <foo-2 /> <foo-3 /> <foo-4 /> ... <bar-1 /> <bar-2 /> <bar-3 /> <bar-4 /> ... <something-else-1 /> <something-else-2 /> </row> </root> I want to get all the "foo" nodes only, avoiding the use of loops if possi...

Greasemonkey (JavaScript) textarea question

I have written a basic Greasemonkey script which passes an output out to a textarea, like this: var obj = document.getElementById("comment").innerHTML = "\n" + "Note:" + "\n" + "\n" + output_string; It works like a charm, if you change the value from the source, it will update the textarea. However, as soon as you write anything yours...

How can I position an element next to user text selection?

I need to position an absolute positioned button next to user's selected text. just like what IE8 does internally. I'm binding a jquery event mouseup to the Document, and get the selected text. but I'm currently out of ideas how to know where the actual selection is positioned, without wrapping it in some element, because selection of ...

How to use jquery in php file?

I am currently creating a table with php and data from a mysql db... So I need to use Jquery in the table.... How can I do this? Im guessing I have to import the library somehow? Thanks ...

How to force a page to reload if all what was changed in url is hash?

I am trying to reload current page with different url hash, but it doesn't work as expected. (Clarification how I want it to work: Reload the page and then scroll to the new hash.) Approach #1: window.location.hash = "#" + newhash; Only scrolls to this anchor without reloading the page. Approach #2: window.location.hash = "#" + ne...

Problem printing contents of Canvas tag (Chrome, Opera)

These browsers (Windows versions) correctly print a web page which has a canvas overlay over an img tag image: IE6, IE7, IE8, Firefox, Safari But Chrome (up-to-date as I type this at version 3.0.195.27) and Opera (up-to-date as I type this version 10.0 build 1750) don't. Chrome ignores the canvas rendering entirely. Opera renders the e...

Form calculator using Each() and Children() in jQuery

Im trying to build a form that calculates a total price based on a series of drop down boxes with string values such as "This option costs £30" i know this is not ideal but im putting this together as a hack for an existing script For the most part ive got it working however im not sure how to run the each function for each child of #pr...

How do you implement a Stack and a Queue in JavaScript?

What is the best way to implement a Stack and a Queue in JavaScript? I'm looking to do the shunting-yard algorithm and I'm going to need these data-structures. ...

Is there a simple way I can tokenize a string without a full-blown lexer?

I'm looking to implement the Shunting-yard Algorithm, but I need some help figuring out what the best way to split up a string into its tokens is. If you notice, the first step of the algorithm is "read a token." This isn't exactly a non-trivial thing to do. Tokens can consist of numbers, operators and parens. If you are doing some...

Classic ASP "ExecuteGlobal" statement acting differently on two servers

I have a strange problem that I don't really know how to handle. In addition to developing a new ASP.NET site, I have to support the old "Classic ASP" site. It's written in VBScript with a batch of Javascript functions as well. Many of the Javascript functions are in 'include files'. Debugging these hasn't been a problem once I learn...

Tooltip using Prototype.js

It seems so hard to find a easy to use tooltip for Prototype library. The ones that are out there are so bloated. What I am looking for is something as simple as this. <a class="tooltip">This is my sentence<span>Tooltip is here</span> that ends in sorrow.</a> <a class="tooltip">How can I make this happen <span>like how?</span> without ...

jQuery conflicting hover/toggle states in IE?

Here's my code: <!doctype html> <html> <head> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"&gt;&lt;/script&gt; <style type="text/css"> label {display:block; width:300px; height:20px;} label.selected{background-color:#a33;} label.hover{background-color:#ccc;} </style> </h...

Are there any free solutions that provide intellisense for JavaScript?

Are there any free editors that come with auto-complete / intellisense for JavaScript programming? As I try and do more complicated JavaScript programming I find my lack of ide/intellisense/compiler to really be a source of frustration. Any JavaScript environment tips? ...

Uploading 'canvas' image data to the server

I need to upload the canvas image data to the server (database) on the fly, i.e., I need to create a form and with an input=file, and post the image data without any user interaction. ...

Download JSEclipse plugin stand-alone

Is there anywhere I can download the stand-alone JSEclipse plugin, it seems like it only comes bundled with the trial edition FlexBuilder plugins. It used to be available here: http://www.interaktonline.com/products/eclipse/jseclipse/overview/ I still find it useful to use but I'd rather not have the cruft of an expired Flex builder tr...

ASP.NET How to pass container value as javascript argument

I am using an oBout Grid control with a template on a textbox. I would like to pass an argument to a javascript, the current row index of a grid when a user clicks on it. But the result of onClick='setGridInEditMode(<%# Container.RecordIndex %>);' /> comes out as onClick="setGridInEditMode(&lt;%# Container.RecordIndex %>)...

Why does appending a <script> to a dynamically created <iframe> seem to run the script in the parent page?

I'm attempting to create an <iframe> using JavaScript, then append a <script> element to that <iframe>, which I want to run in the context of the <iframe>d document. Unfortunately, it seems I'm doing something wrong - my JavaScript appears to execute successfully, but the context of the <script> is the parent page, not the <iframe>d doc...