javascript

Setfocus to textbox from JavaScript after just creating the textbox with JavaScript?

So I just created a textbox with JavaScript like this: EDIT: Added the len variable var len = tbl.rows.length; var rtb = tbl.insertRow(len); var cName = rtb.insertCell(0); var cDis = rtb.insertCell(1); var cDur = rtb.insertCell(2); ...

Is there a simple library that will render JSON objects as trees?

So, is there a VERY simple library that will render JSON objects as trees? I know that this can be done in many ways (such as YUI), but for debug purposes I'd like to simply be able to view a JSON objects I receive from a server as a tree, nothing fancy (but collapsable tree's would be a bonus). The kind of solution I'm looking for wou...

How to use jQuery (or similar) to extract all of the CSS

Given a web page that has loaded (possibly several) CSS files, and inline styles, through the use of: <link rel="stylesheet" type="text/css" href="some_file.css" /> <style type="text/css"> /* some css rules */ </style> <link rel="stylesheet" type="text/css" href="some_other_file.css" /> <style type="text/css"> /* some other css rules *...

Reference asp.net control by ID in javascript?

When asp.net controls are rendered their ids sometimes change, like if they are in a naming container. Button1 may actually have an id of ctl00_ContentMain_Button1 when it is rendered, for example. I know that you can write your javascript as strings in your cs file, get the control's clientID and inject the script into your page using ...

Javascript: negative lookbehind equivalent?

Is there a way to achieve the equivalent of a negative lookbehind in javascript regular expressions? I need to match a string that does not start with a specific set of characters. It seems I am unable to find a regex that does this without failing if the matched part is found at the beginning of the string. Negative lookbehinds seem ...

does this jQuery code snippet cause any memory leak?

I am wondering if the following jquery code causes any memory leak: $( function() { var parent=$('table#mytable tbody').get(0); $('tr:last', parent).click(function(){...}); }); For my understanding, $('tr:last', parent) is the last row which is the DOM object, but in the anonymous function, the closure has this DOM obje...

yet another cross frame scripting question - getting selected text

I've been struggling with a problem for a few hours now, and I would appreciate either some help in accomplishing my goal, or confirmation that what I'm trying to do is in fact impossible. I have a webapp that takes the selected text (document.getSelection()) as input, from an arbitrary webpage. While it would be possible to use a bookm...

Javascript window resize event

How can I hook into a browser window resize event? I see there's a jQuery way of doing it but I would prefer not to bring this into my project for just this one requirement. http://stackoverflow.com/questions/599288/cross-browser-window-resize-event-javascript-jquery ...

Firefox onkeydown detect pressed key

From an input text I need to call a function to capture the onkeydown event and I need to pass a parameter to that event, for example: <input type="text" onkeydown="TextOnKeyDown('myPrefix');" />... Then in that function I need to know what key was pressed. I use function TextOnKeyDown(prefix) { var key = event.keyCode; ... ...

Effective ways of finding an element in a Javascript array

I am using an array with titles. Each titles index corresponds to an id in a database which contains html for that given title. Lets say I have a string which contains one of the titles. title = "why-birds-fly"; titles[] // an array which contains all the titles To use the string "title" to get the corresponding id I could do: for (...

using __dopostback(UpdatePanel) from a UserCtrl in a WebPartZone

I hope someone can offer a little assistance with this. I have a button which when clicked presents a javascript generated OK or Cancel. Once the user clicks on OK it fires a __DoPostBack clientside and targets an UpdatePanel which processes the postback asynchronously. I then use ScriptManager.RegisterStartupScript() and pass in a jav...

Dynamically Scrolling a Textarea

Hello All I have a textarea html element on my page that gets reloaded via ajax. The whole textarea is returned each time not just its content, and the content grows over time. Along with the textarea i return the following piece of javascript: <script type="text/javascript" > var textArea = document.getElementById('outputTextResult...

How to convert string into float in javascript?

I have a datagrid and I get 2 column's value by javascript. These fields are numeric and when fields have comma (ex. 554,20), I cant get the numbers after comma. I tried parseInt, parseFloat. How can I solve it? ...

Problem with Javascript and form duplication

Hello. I have a HTML code that goes something like this: < tr id="500" > < form id="500" onsubmit="DoThis()"> < td>Info< /td> etc... etc... < td>Info< /td> < /form> < /tr> What i am trying to do in Javascript is to make a copy of the element and add it to parent table: var TrElement = document.getElementById("500") v...

What's your favorite way of testing javascript code snippets?

What's your favorite way of testing javascript code snippets? I like to use the browser's address field directly: javascript:void(document.getElementById("textbox").style.display='none')) javascript:void(document.write("Testing")) javascript:alert(parseFloat("33.33")) If using the latter trick, don't forget to wrap everything in a vo...

How can I validate a sentence using PHP and JavaScript?

I am currently trying to validate if the sentence a user enters matches the expected sentence. The expected sentence is stored in a PHP variable $rebuiltSentence, for example 'the cat sat'. The problem is that when I try to call my JavaScript function formSubmit() I need to give it the sentence to check, therefore ideally I would call f...

Setting location.hash in frames.

I am using ajax to update the location of a page in a frame. But when setting the location of the hash (on Chrome and some versions of IE (5.5) specifically, but occasionally on IE7) the page is being reloaded. The following html demonstrates the problem. the main frame.... frame.html is <html><head> <frameset rows="*"> <frame src=se...

What's the correct way for a cross-browser HTML layout?

I just read codes of a web product that is supposed to support multiple modern browser(including FireFox 3.X, Safari 3.X and IE7+, but not including IE6-). The HTML code uses div instead of table to create table-like effects. Actually, the div's are organized like this: <div> <div> <div style="float:left" id="h...

Weird html error...

I have a list of links that are exhibiting some really weird behavior. The code is: <ul id="home" class="panel" title="title_here" selected="true"> <li><a href="#search">Search for Name</a></li> <li><a href="#browse">Browse by Department</a></li> </ul> It is part of an iPhone site, using the iUI framework. I know uiUI is bette...

IE cookie quirks

We are facing an issue where the following check fails intermittently in IE: pseudocode: setCookie("name","value", "1d"); if(getCookie("name") === "value"){ return SUCCESS; } else { return FAILURE; } this little routine checks if the user has cookies enabled. it shouldnt fail but it does. is it because IE can only handle a cert...