javascript

Which event handler to use to record leaving page - onunload or onbeforeunload?

Hi all, Having not any answers to my previous questions about using javascript to measure page turn times, I'm going to start writing my own code (!). To measure the length of tie it takes, I'm proposing dropping a cookie containing a timestamp when the user browses away from a page, then in a subsequent page, comparing that time with ...

jqGrid filtering on the client-side using "filterToolbar"

Hi guys, I have to add filtering to a jqGrid that is completely managed on the client side (data is only loaded once from the server). I need to use filterToolbar in order to filter the grid data, but couldn't find info if there is a default search mechanism on the client side. Is a server-side search the only way to do this? Thanks, ...

Cancel request in google ajax api

I'm doing small AJAX searchbar with "new google.search.WebSearch();" from Google AJAX Api. How do i can cancel an ongoing ajax request? I usually do a: var xhr; function Something() { xhr.stop(); xhr = $.get .... } in jQuery. What is the equavalent for the Google websearch object? ...

jQuery .ready() automatically defining variables for each element with ID in DOM

I have noticed some unexpected behaviour when using the jQuery .ready() function, whereby afterwards you can reference an element in the DOM simply by using its ID without prior definition: <html> <script src="jquery.js"></script> <script> $(document).ready(function() { myowndiv.innerHTML = 'wow!' }); </s...

removeAttribute do not return true or false

Hi , I am trying to remove attributes of a DOM element using below statement in javascript. var res = nodes.removeAttribute("style"); but the res is always "undefined" it seems that the removeAttribute function does not return anything (I tested it on firefox browser) How can I identify that the attribute is successfully removed o...

What is the easiest method to get the selection in input text field ?

How could I get the selected text in the following code ? I working with Firefox 3.6.3 (currently not interested in other browsers). HTML: <input id="my_text_field" type="text" /> <div id="log"></div> JavaScript: $("#my_text_field").select(function() { var selected_text = "Something selected"; // What should be here ? $("#log...

Is there any plugin which will help me validate model on client-side?

I need to validate form on client-side and I was wondering if there is a rails plugin which will help me in this task? Maybe it will build javascript needed to validate certain model from ActiveRecord validations? ...

iPad HTML Prototype: Which JS Framework?

Hi, are there any Javascript frameworks (such as iUI) available for building iPad prototypes? I have found nothing useful so far. Best, Stefan ...

Using Javascript to get URL Vars, not working when multiple values present in QueryString

Hi, I am using a Javascript function to get the values of a URL to pass to jQuery using the function below: function getUrlVars() { var vars = [], hash; var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&'); for(var i = 0; i < hashes.length; i++) { hash...

Cufon: links change size on hover and stay that way

I have text links in a paragraph which is replaced using Cufon. For some reason, when I hover over the links, the text in them gets wider, and stays that way when I move the cursor away. A colour change, added to hover in the css, reverts as one would expect. So it isn't "stuck" in the hover state as far as I can tell. When I turn javas...

HTML: how to create a "save as" button?

In your browser, when you want to save an HTML page that you are currently viewing, you normally go to the File menu and click Save As. Can I have a little button at the bottom of an HTML page that does the same thing? So instead of going to the File menu -> Save As, I want my user to be able to click the button to save the page on to ...

Javascript: Remove checked status from disabled input on load (already checked)

On load, the script is not un-checking the disabled checkboxes, I have tried everything. I have even tried running this code from Chrome Console, and it is working, but not in normal ways. Where is the error? (Note: I'm using prototype framework library) Javascript: document.observe("dom:loaded", function() { $(document.body).selec...

Can i have a flash movie communicate with Shadowbox jquery overlay?

I want to have my overlay adjust in size depending on how much content is being shown in the flash movie. Also, I want it to resize in real time when the user adjusts the content. Is it possible? ...

jQuery UI - Sortable isn't firing?

Hi, I'm trying to get the jQuery UI sortable plugin to work and I've created a list that looks like this: <ul id="sortable"> <li>Item 1</li> <li>Item 2</li> <li>Item 3</li> <li>Item 4</li> <li>Item 5</li> </ul> And I've included the plugin script files: $(function() { $("#sortable").sortable(); alert('test...

Javascript "inlet" or "offset" function for drop-list options

I have seen on several sites that drop list values can have offsets... For example this drop-list: Fruits Apple Banana Orange Colors Red White Black The above are all options, but some have "inlets" or "offsets" or whatever you want to call it. How is this done with js? (regular js, not jquery at the moment) Thank...

Remove header and footer in html to print page

Hi all, Is there any way to remove header and footer of a html page, so that if user print it, there is no header and footer. User can choose to remove it using print setup, but i wondering is there any css or javascript to remove it programatically? thank you for any response. ...

Problems with noobs putting my GA code into their sites

I don't mean for the title to be derogatory, but this is a rather frustrating problem, and I'm looking for a good workaround, given a language barrier involved. I have a site set up for a plugin I wrote, and, rather than use the site's resources to write their own code, I've had people simply rip the code from the samples on the site. N...

jQuery iBox (lightbox clone) and IFRAMES

Hey there you lot, is there a way that I can open a lightbox (in this case iBox) from within an IFRAME and have the actual lightbox open in the Parent page? sigh I am confusing myself here! ...

Javascript/jQuery HasLoaded or equivalent?

I know in jquery it is possible to call the javascript/jquery onload()/load() functions on, for example an image (<img>). However, if in jquery if i use .html(htmlString) to insert an image after the dom has loaded, how can i add a listener to handle the images onload event? Is there a property I can check to see various images and if t...

JavaScript Library Design

I have a general question about the design of JavaScript Libraries. I am trying to consolidate common methods into one js file so they can be reused by different scripts. I have taken a look at how the JSON library is structured and believe it was a good approach. JSON for Javascript. So they start off creating an instance of the cl...