javascript

Algorithm of JavaScript "sort()" Function

Recently when I was working with JavaScript "sort()" function, I found in one of the tutorials that this function does not sort the numbers properly. Instead to sort numbers, a function must be added that compares numbers, like the following code:- <script type="text/javascript"> function sortNumber(a,b) { return a - b; } var n = [...

Problem creating jQuery plugin with textareas

I'm trying to modify this script that emulates the Word 2007 minibar in a textarea. I have wrapped it in a plugin, the problem is that it will not work with multiple textareas. You can try it out at JSBin (Just select som text in the first textarea and then click on the "b") Can someone help me? I'm kinda lost. Update Should have m...

How to focus window/tab like alert()?

If in some of my tabs alert() is executed, then this tab becomes selected instantly. The thing is - this alert() box is ugly. I have created with my design and all.. But when I call it - tab is not selected/focused. window.focus(); does not work. Any ideas? ...

android: webview not loading javascript with custom WebViewClient

I've got a very basic WebView which works until I try to add a custom webViewClient where it stops processing JavaScript. Am I doing something wrong? Is there another way to get rid of the address bar and menu options in the WebView? browser = (WebView) findViewById(R.id.webkit); WebSettings webSettings = browser.getSettings...

How to detect file drag on HTML page

I can detect if a file is being dragged on a div by listening to 'dragover' event. But how can I detect if a file is being dragged over the whole HTML page? document.body does not seem to raise the 'dragover' event. What I intend to do is as soon as a file is dragged over a page, I'll show a hidden div to drop the file on. Just like Gma...

Retrieve information from URL using Jquery

Suppose I have an url like : http://localhost:1122/MyProject/MyPage.aspx?from=home&amp;id=454. I can retrieve the 'form' value in code behind like Request["from"].How can I do the same using Javascript?Can I do this using Jquery also?If yes how can I do this? ...

Google Maps API, distance from metro stations

How can I get the list of e.g 3 nearest metro stations from specified point and the distance from the point to station? ...

How DOM works/is loaded? (in HTML)

Hi All! How DOM is loaded in a html page? First is load the all html tag ( ) and inside of this element is created an other element and so on or first is create followed by ... and finally, the closing tags are added? Thank you! ...

Error removing child div second time

I am using prototype 1.6.1 to insert and remove a div as a first child of another div. So I have parent div 'A' and I do $('A').insert(divB,'top'); then later $('B').remove(); This works fine, but if I create the same div a second time and then try to remove it again I get an error that $('B').parentNode is null. But if I look at ...

Enabling chained method using ".delay"

Hi, all. I'd like to know how to realize this method-chain style: var foo = function(){}; foo.prototype = { say : function(s){ alert(s); return this; }, delay : function(ms){ var _this = this; setTimeout(function(){ return _this; }, ms); return this; // If I omi...

Call a (Rhino) JS function in Java and pass a variable in

Hi, after figuring out yesterday how to configure my Eclipse project to be able to run JS code (if your interested: http://stackoverflow.com/questions/3417958/), I have the next question related to this topic: I got a JS file and a function within it. I need to run that function inside my Java code and to pass a (Java string) variable i...

Using plugins that are not updated anymore

I have a simple question: Would you rather use a plugin that is actively developed by the author(s) or use a plugin that is good in your perspective, but you know that it was last updated years ago and has no active support? ...

my overlay is not being centered using css

<head> <title>Overlay test</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <style type="text/css"> #overlay { position: absolute; background-color: #ccffcc; display: none; height: 200px; margin: 0 auto; width: 200px; } </style> <script type="text/javascript"> //<![CDATA[ function...

How to implement css fixed property via javascript?

Hi. I'm trying to imitate css fixed property via javascript. Don't ask me why I need to perform this crazy action (no, it is not about IE6). Here is the simplest, naive approach: <html> <style> .fixed{ outline: 2px solid red; width:100px; height:600px; po...

Which one is better "Prototype" or "jQuery"

I have made an application, in which want to use one of the javascript library. Have any one idea which one I should use and why? Thanks in advance ...

Running function only if a certain element isn't burring

Hi, im making an application that creates a text input where ever you click. I was having a problem where whenever you would click inside the field another text field would appear but i managed to fix that. I have one last major issue that I just can't solve. I know ou can't use blur() and focus() as arguments (though it would be nice) b...

javascript alert not firing

I have a new page with the following: The Response.Redirect works, but I don't get a popup before hand... Any ideas??? protected void Page_Load(object sender, EventArgs e) { if (Request.QueryString["timeout"] != null && Request.QueryString["timeout"].ToString().Equals("yes")) { Response.Write("<script>alert('Your Ses...

JQuery Multi File Upload

I have a problem in which I need to upload multiple files using multipart POST request, I need a single browse button to choose the uploaded files. I've seen JQuery Plugin for multi file upload, but there is a problem that only one file is uploaded several times. the post request file parameters are sent with the same name. My question i...

I need to perform an action based on which radio button is selected (by jQuery), but neither jQuery's click or change method is doing what I want

In the callback of a HttpRequest I have, I run this jQuery code: $("input[value='"+data.notetype+"']").click(); So the radio button with the value of data.notetype is selected. This works fine. But I need to perform an action based on what button is now selected. If I use the change() method like this $("input[name='note_type']").ch...

How to restart a gif animation on a new page?

I made a GIF animation running for a few seconds, and is not looped. When I put the gif on different pages, the animation does not restart because its cached... it just stays on the last frame. How can I make it restart when it is on a new page? I know of ways how to rename it or add "?" to it, but it will give me bandwidth issues. Any ...