javascript

How can I get reason of page unloading in javascript's onunload event, in IE?

There may be different reasons of page unloading: 1 User closes the current window. 2 User navigates to another location. 3 Clicks the Back, Forward, Refresh, or Home button. 4 User submits a form, and then browser starts to unload current page and load page with results of form submitting. (Assuming that the current window is the fo...

Unable to `submit()` an html form after intercepting the submit with javascript.

I'm trying to intercept the submission of a form in order to change the value of my keywords label. I have the following code: <HTML> <FORM name="searchForm" method="get" action="tmp.html" > <input type="text" name="keywords" /> <input type="button" name="submit" value="submit" onclick="formIntercept();"/> </FORM> <SCRIPT language="Ja...

What's the difference in those declarations (in JavaScript)?

Possible Duplicate: Javascript: var functionName = function() {} vs function functionName() {} In Javascript I can write: function TheFunc(arg) { ... } or TheFunc = function(arg) { ... } or TheFunc : function(arg) { ... } What's the real difference and when should I use which? ...

JavaScript: Keeping track of eventListeners on DOM elements

What is the best way to keep track of eventListener functions on DOM elements? Should I add a property to the element which references the function like this: var elem = document.getElementsByTagName( 'p' )[0]; function clickFn(){}; elem.listeners = { click: [clickFn, function(){}] }; elem.addEventListener( 'click', function(e){ clickFn...

Whats faster in Javascript a bunch of small setInterval loops, or one big one?

Just wondering if its worth it to make a monolithic loop function or just add loops were they're needed. The big loop option would just be a loop of callbacks that are added dynamically with an add function. adding a function would look like this setLoop(function(){ alert('hahaha! I\'m a really annoying loop that bugs you every t...

Binding keys with javascript while preventing the browser shortcut keys

I'm making a javascript game and need to bind a lot of keys to different functions. This I know how to do, what I need some help on is over-riding the shortcut keys for the browser. in other-words I want to blur hot keys for the browser and divert them to my application. ...

I'm building a javascript app, I need a lightweight php script to interact with a database and javascript using json.

My app is a very complex game that uses json objects to store its execution state (aka save games). I'm looking for a nice database script that can talk json and interact with javascript via ajax. ...

How to find with javascript if element exists in DOM or it's virtual (has been just created by createElement)

Hello. I hope a topic is self describing. I'm new on your site, it helped me much times but this time i was surprised not to find an answer on internet. The question is quite simple. Say, i have an element created in code: var elem = docuemnt.createElement('div'); ... I wish sometime to check have i placed it into the DOM bef...

How to remove only tag using jQuery?

<div> <ul> <li><a href="#"><span>link</span></a></li> <li><a href="#"><span>link</span></a></li> </ul> </div> Hi I want to remove the span using jQuery, I have tried the .unwrap(); but its not working. please do needful. ...

Using javascript in Crystal Reports formula editor

How can I go about using java-script in Crystal Reports formula editor ? I wish to write a function that will use Google Translation API to modify the report's data. Thanks ...

Why does setting input value take 600ms?

I an setting value for an input tag in firefox. If I set it to a literal string, there is no delay. The delay only happens when I try to set the value to that of an object property (contains a string), then it takes 600ms. a) document.getElementById('inputtag').value='test' // No delay b) object.testvalue='test' document.getElemen...

how to hide a window

Like window.open(); window.close(); Do we have any facility to hide a window. I have a window opened on a aspx page. That window has a button which opens second window. When 2nd window is opened I want to hide the 1st window. Is there a way? Plz Suggest me. Thank You. ...

Write an expression in javascript

hi everybody... I need a javascript code that split a string like below: Input string: "a=>aa| b=>b||b | c=>cc" Output: a=>aa b=>b||b c=>cc I'd written different codes like: split(/ \ | /) or split(/ \| (?! \ |) /) but didn't work. please help me... I really need it fast. ...

Detecting when a Flash file has finished playing in Javascript

I'm using Javascript to embed a flash file into a website which I then need to remove once it's completed playing. Is there a way to do this in plain Javascript? Or will it require a callback type function to be added into the Flash file itself? How do I code this? ._. Javascript: jQuery('body').append('<embed id="flashIntro" width="...

Sliding panel in the middle of the page. Z-index given not working

Hi all, I am implementing sliding panel element but problem is when i slide out other div element is floating down. I guess and tried to give z-index to element which i am sliding but it doesn't seems to work. Let me put code for both div. <div class="vrcontrol"> <div class="slide-out-div"> <a class="handle" href="http:...

Asp.net Jquery Autocomplete problem

Hi all; my problem cache, each keydown request no cache help me $('[id$=Name]').autocomplete('AComplete.ashx',{ extraParams: {Type: function() { return $('[id$=Check2] option:selected').val() } } }).flushCache(); how to make cache prevent ? ...

Google Ajax search API

Hi Folks, I'm wondering, is it possible to receive google results over their own ajax API in a way like, 100 results per page? Without a visible search field, I'd like to get the results in the background to create a progression for some search phrases. My basic question is, what are the restrictions of the google search api ? --upda...

jquery multiple select x rails edit action

Hi, i'm using the JQUERY multiselectable plugin. Because it's get one select box and transform it in two, where you can move one selected option to another select box. The problem is that i'm facing some problems with the edit action. When i load the form, the selected values (that are saved in my model) are not being populated in th...

Javascript this points to Window object

Hi, I have the following code. I expected to see "archive" object on my firebug console, but I see Window object. Is it normal? var archive = function(){} archive.prototype.action = { test: function(callback){ callback(); }, test2: function(){ console.log(this); } } var oArchive = new archive(); oArchi...

API Key Error in Facebook Connect (javascript sdk)

Hi, I am trying to implement Facebook Connect on a website. I am trying to work with Javascript SDK of Facebok. I am new to it and unfortunately most of links provided in Facebook WIKI are out of date... Returning 404 not found. Anyway I added this code before the ending </body>: <script src="http://static.ak.fbcdn.net/connect.php/js/F...