javascript

jQuery load with variable, and split into 2 parts?

I'm looking for a way of increasing the performance of my code. Currently I do something similar to this: $(".div1").load("Page.aspx #section1"); $(".div2").load("Page.aspx #section2"); However, this means I'm having to make 2 GET requests. Is there any way of reducing this to 1 request by doing something like this: var content = $.l...

javascript onblur onfocus

I have a page with embedded content where a user is tracked using AJAX GET requests. When they change tab/minimize window the window.onblur event stops the tracking, when they return window.onfocus starts the tracking again. This all works fine, until I introduce this embedded element (with a fullscreen option). So I have used a series ...

Multiple instances of the same option?

I'm passing options to the qTip plugin like so: hide: { when: { event: 'unfocus', event: 'inactive', event: 'click' }, }, It appears to be working but should I bundle those 'events' somehow? ...

Can Adobe Air do this?

I've written a lot of JavaScript before, and adobe air looks really interesting, my question is can Adobe Air: Access ICC profiles stored on a users computer Detect which ICC profile the monitor is currently using Use the SDK for specialist USB hardware Do all this one both Windows and Mac computers Thanks for any information. If no...

Need to identify position within raw html of user text selection in browser.

I am well aware that this is an unusual thing I'm looking to do here, but just trust me, yes I do need to do this. It's all about pattern matching within the raw html (same as view source) for a web page. If a user selects some text in a web browser, I want to be able to say - that selection is at position (say) 1234, (or there abouts) ...

how to implement javascript "star" function of Google search result page?

Hello everyone, When in Google search result, in each entry of search result, there is a "star" nearby, and end user could click the star to indicate whether the result is good or not. I believe this function is implemented in Javascript. My question is, I want to implement a similar function in my own web application. Which is there i...

What does "?", used after JavaScript filename, means?

For example, having: <script type="text/javascript" src="http://somedomain.com/js/somejs.js?14"&gt; </script> So what does "?14" means here? ...

Why is doLayout not working on second click?

Hi there, I am using the doLayout function on a window. var win = new Ext.Window({ id: 'site-action-window', closeAction: 'hide', resizable: false, layout: 'fit' }); function showWin(f) { win.removeAll(); win.add(f); win.setSize(400, 150); win.setTitle(localize.addLanguage); win.show(); ...

Simple question: Do I need to specify width, height of "image" when preloading images?

I have this code: if (document.images) { preload_image = new Image(25,25); preload_image.src="http://mydomain.com/image.gif"; } First of all, will this work in all major browsers? Secondly, do I need to specify the width and height like in the code? Lastly, will this preload my images and cache them? Thanks ...

In javascript, what is a constructor? And what isn't?

I'm using a plugin for jQuery. It works great in webkit, but when I try it in firefox I get the following firefox error: google.maps.Geocoder is not a constructor $('.to, .from').geo_autocomplete(new google.maps.Geocoder, { Here is all the jquery: $('.to, .from').geo_autocomplete(new google.maps.Geocoder, { mapkey: 'ABQIAAAAbnvDoAoY...

Reload contents from the log file on the page using AJAX

I am running a shell script in the background and redirecting the output to a log file in php. I want to display the contents from the log file on the page. I am able to do that using the code below. <?php $logfile = "hello"; ?> function displayOutput() { var html = <?php echo filesize($logfile) ? json_e...

Refactoring JavaScript and PHP code [Job Interview]

Hi, recently I had a job interview. I had two tasks: 1) to refactor a JavaScript code // The library 'jsUtil' has a public function that compares 2 arrays, returning true if // they're the same. Refactor it so it's more robust, performs better and is easier to maintain. /** @name jsUtil.arraysSame @description Compares 2 arrays, re...

Upload data:image image without user interaction in a Google Chrome Extension?

I am making sort of a Parental Control Monitor extension thing; for a friend. Would there be any way to upload the images taken using the captureVisibleTab method? The data:file path cannot be saved and checked again, because the parent wouldn't be using the same computer. ...

How to create a drop down menu with a table?

I'm trying to create a drop down menu similar to what you would see with a 'ul'. The difference being I want to do it with a table. When the page loads I have td's with their 'display' attribute equal to 'none'. This hides the td for me. The problem is in the javascript below. function displayMenuOptions() { var _1 = do...

How to remove all child nodes from parent using FBJS

So, I need to remove all the child divs from a parent div using FBJS. I basically want to end up with an empty container div. Here is the code that I am using right now. var events_next = document.getElementById('events-next'); for(var i=0; i < events_next.getChildNodes().length; i++) { events_next.removeChild(events_next.getFirstChil...

activate/deactivate javascript on button click

I am using a javascript to zoom an image on my asp.net web page. I want to put 2 buttons on it like "Zoom" "Cancel Zoom" and accordingly activate/deactivate the javascript functionality. Right now I have a css class on which the javascript operated to produces the zoom effect. The image is like: <a id="big" href="source of image" class...

Getting "method undefined" when it is CLEARLY defined in JS

I have a very simple bit of code (relies on jQuery): var dom_builder = function() { this.table = function(elem,attributes) { return $("<table>").attr(attributes).appendTo(elem); } }; console.log(dom_builder.table); Now when I try to run it I get the following error: Uncaught TypeError: Object # has no method 'table'...

Can I run arbitrary javascript code in the javascript:void() function using the browser's address bar?

I was wondering if I could run a block of code(which includes for loops and if statements) in a javascript:void() function through the URL box. ...

Retrieving a property of a JSON object by index?

Assuming this JSON object: var obj = { "set1": [1, 2, 3], "set2": [4, 5, 6, 7, 8], "set3": [9, 10, 11, 12] }; The "set2" property may be retrieved like so: obj["set2"] Is there a way to retrieve the "set2" property by index? It is the second property of the JSON object. This does not work (of course): obj[1] So...

google maps v3 zoom_changed event does not fire when zoom changes

I have a v3 Google map being loaded exactly as I expect and the marker does what I intend. However when I change the zoom, the zoom_changed event that I have added does not appear to fire. Would anyone be able to shed any light on why? My code is below. function map_initialise() { var mapCentre = new google.maps.LatLng(53.75, -1.50)...