javascript

Why are javascript programs delivered in plain text?

Why was it decided to ship javascript programs in plain text? Was it to achieve performance enhancement or the authors never imagined that javascript will be used in much more complex applications and developers may want to protect the source code? ...

How do you use $.getScript with ajax content?

I am loading an external page that relies heavily on jquery into a div with the $.ajax(); method. The obvious problem is that the new content needs to be binded to the dom for jquery to work... Everyone talks about just using $.getScript to do this but I can't get it to work. Can some one give me an example and not just a link to the j...

Inject String into Page Source in Real Time...Possible ?

Hi, I wonder if we can add a string into pagesource in real time.. to give an example, and the thing I want to do is to control timestamps of Divx Videos.. Let me give u an example.. http://www.movshare.net/embed/v5alr3gpmu2nt/?width=720&height=306 when we push play button in this video link it will generate following paramete...

Javascript/ExtJS: "Conditional Inheritance"?

We are using ExtJS for a webapplication. In that application, we use the standard Ext.form.ComboBox control when a simple dropdown is required, and the Ext.us.Andrie.Select control when we need a dropdown where you can select multiple values and/or clear the value. Creating either of these always requires a bunch of boilerplate code for ...

JQUERY won't work on local machine

I'm trying JQUERY on my machine, but for some reason, nothing seems to work. Here's the test file: <html> <head> <script type="text/css" src="jquery.js"> </script> <script type="text/javascript"> $("p").mouseover(function () { $(this).css("color","black"); }); $(document).ready(function(){ $("body").css("background-...

Position of Div in relation to the Top of the Viewport

Hi Everyone: I am wondering how I can get the amount of pixels (or measurement in general) from a div to the top of the window in Javascript. I am not looking for an offset y in relation to the document, simply to the top of where the browser is displaying. I tried the "answered" solution here: http://stackoverflow.com/questions/21170...

javascript, can't retrieve sibling nodes

I've been at this for a while and I can't seem to crack it.. I have some javascript trying to hide sibling divs, besides the one that is passed through the function. Here's the html: <div id = "chat_content"> <div id = "chat_content_1">This is div one</div> <div id = "chat_content_2">This is div two</div> <div id = "chat_content_3">T...

What are the differences between these two javascript cases?

var foo1 = function () { return { init: function () { alert(this+" hello foo1"); } }; }(); var foo2 = { init: function() { alert(this+" hello foo2"); } }; foo1.init() foo2.init() The differences I see are: the first is "closure-style", while the second is not. the first defined a f...

jQuery fadeIn() not working properly

jquery: $.post("process_login.php", {username : $("#username").val(), password : $("#password").val()}, function(data) { $("#login_results").fadeIn("slow").html(data); } ) html: <table> <tr><td id="login_results"></td></tr> <tr><td><input type="text" id="username" /></td></tr> <tr><td><input type="password" i...

Converting a simple XPath query to an E4X query

One might think the corresponding E4X query for the XPath query, //*[@foo = "bar"], would be ..*.(@foo == "bar"), but that will throw an error whenever it gets to an element without a foo attribute. I am currently using ..*.(function::valueOf().@foo == "bar") instead. My question is if there is another, less of a hack-way to do this. ...

How to create a 20x20px cell grid background programmatically?

I'm trying to build a grid the size of the browser window that has 20x20px squares. My first idea was to just construct a table with the following code, but IE8 (in any mode) will not render the cells unless they have non-white space content. According to this, it will if it has a &nbsp;, but from my testing, it only works if the table i...

How do I change the color of text in javascript?

I wrote a javascript code displaying the date. How would I change the color? ...

make output parallel with php code based

Hi all, I need your some help... How to create parallel output from many pages in one pages, see examples: I store all data in plain text e.g. old-book-version.txt 1:1 dadidedodu.... 1:2 cacecocuci.... 2:1 papopupepi.... 2:2 lalilolule.... 2:3 and more...... mid-book-version.txt 1:1 dedadodedu.... 1:2 cacicecuca.... 2:1 popapepupi......

How to prevent saving in global variable to know the last clicked radio button?

I am trying to implement a grid with radio button selector. When the radio button is clicked, the row is set to a different color. Also, when a radio is selected in the grid, it needs to see if there was a previously selected radio button so that it could change the color set. <script type="text/javascript"> var lastSelectedId = ''; fun...

Unique values in an array

I have an array of numbers that I need to make sure are unique. I found the code snippet below on the internet and it works great until the array has a zero in it. I found this other script here on SO that looks almost exactly like it, but it doesn't fail. So for the sake of helping me learn, can someone help me determine where the prot...

anonymous functions considered harmful ?

The more I delve into javascript, the more I think about the consequences of certain design decisions and encouraged practices. In this case, I am observing anonymous functions, a feature which is not only JavaScript-provided, but I see strongly used. I think we can all agree on the following facts: the human mind does not deal with m...

Event Binding - JQuery vs Javascript

What are the differences between using $("#element").click(function() { alert("test"); }); and <div id="element" onclick="alert('test');"></div> Is there any difference in performance, functionality or anything else? Should I be using jquery way, when I can simply use onclick attribute? ...

Javascript Array in Class = How to make it valid

I am using this jQuery validation library on my website. It requires me to put the validation rules in the class part of the input tag. ie <input class="validate[required,custom[onlyLetter],length[0,100]]" name="firstname" type="text" /> Now this causes me to end up with code in mine that looks similar such as: <input type="text" ...

How should I securely store passwords and use http auth in a chrome extension

I'm making a chrome extension that requires fetching an xml file from a secure server. I'm currently using XMLHttpRequest() to make a call to the server https://username:[email protected] which returns an xml object that I can parse and display. I want this extension to be available for more than just my hobby use, so it needs an...

Get computed font-family in JavaScript

This is a followup to this question. I am working on a component for the CKEditor, a tweaked version of the font drop-down menus that always display the currently selected font family / size values, no matter where they were defined, using computedStyle and consorts. As you can see in the other question, determining the font size work...