javascript

How to detect online/offline event cross-browser?

Hi everyone, I'm trying to accurately detect when the browser goes offline, using the HTML5 online and offline events. Here's my code: <script> // FIREFOX $(window).bind("online", applicationBackOnline); $(window).bind("offline", applicationOffline); //IE window.onload = function() { document.body.ononlin...

disable default behavior of links

i have a list of menus <ul> <li><a href="#about" id="about">ՄԵՐ ՄԱՍԻՆ</a></li> <li><a href="#products" id="products" >ԱՐՏԱԴՐԱՆՔ</a></li> <li><a href="#farm" id="farm" >ՏՆՏԵՍՈՒԹՅՈՒՆ</a></li> <li><a href="#gallery" id="gallery" >ՆԿԱՐՆԵՐ</a></li> <li><a href="#contacts" id="contacts">ՀԵՏԱԴԱՐՁ ԿԱՊ</a></li> </ul> and i ...

Hide span (or div) until javascript completes

Hello, I'm using the Unit PNG Fix (http://labs.unitinteractive.com/unitpngfix.php) to make a transparent png work in IE. It's being used on the background image of my logo container. So I have my html, which contains these relative items. In the head: <!--[if lt IE 7]> <script src="/assets/script_unitpngfix.js" type="text/javas...

Iterating over jQuery $(this).attr('class').split(" ") gives odd results

Hello, I've got a page where I'm trying to fetch arrays of classes for lots of divs which share a common class. For example: <div class="common lorem ipsum"></div> <div class="common dolor sit"></div> <div class="common hello world"></div> I want to fetch each common class div and get an Array of it's classes. At the moment, I'm doi...

Viewing HTML response from Ajax call through Chrome Developer tools?

So in my javascript I'm making an ajax call to a service on my website. Whoops, something fails. No problem. Here's what I'd do in Firefox: Open the firebug console Find the failed Ajax call and click the + sign to see more info. The response tab has the raw HTML. Who wants to read all that? I click the HTML tab. Ah, the nicely fo...

chrome fails on jquery form validation

Can someone explain to me why the form validation fails in chrome? http://tinyurl.com/3yphwpl Pressing the submit should colour empty fields red. I have no idea why chrome fails - would be glad to find a solution... $('form .meet').focus(function() { $('form .required').each(function() { if($(this).val() == '') { ...

Javascript XMLHttpRequest Login Promp

I am new to javascript and wrote a simple extension to parse the gmail atom feed and display the number of unread emails. My problem is if for some reason you're not logged into your google account, the extension attempts to check the feed and Safari will display a login box like this. And since I check every 10 seconds these prompts...

JavaScript: Public methods and prototypes

I'm not entirely sure how to implement OOP concepts in JS. I have a class which is entirely declared in its constructor: function AjaxList(settings) { // all these vars are of dubious necessity... could probably just use `settings` directly var _jq_choice_selector = settings['choice_selector']; var _jq_chosen_list = settin...

Automatic userlist update

Hello all, I have a online user list which is populated by a SQL query to a database table. When a new user comes online, how can i make the webpage automatically update? What code do I need to provide? Thanks ...

Drag and dropping using Raphael js

Hi, I'm trying to build a puzzle game in javascript, using raphael to take care of the drag and drop and rotation of the pieces. The problem I'm facing is: Whenever I rotate an image, its coordinate system is rotated as well and the drag and drop doesn't work anymore as expected. Edit2: Here is a simple test case. Drag around the elli...

detect when a window I've opened closes - js

Hi all, I am building a small web app. In the app I open a window using JS: signinWin = window.open("myWindow.htm", "SignIn", "width=600,height=270,location=0,toolbar=0,scrollbars=0,status=0,status=false,statusbar=false,titlebar=no,dependent,alwaysraised,resizable=0,menuBar=0,left=" + 300 + ",top=" + 300); I wish to be notified via e...

How can I handle ArrowKeys and < (Greater Than) in a Javascript function? Which event and which code (charCode Or keyCode)?

How can I handle ArrowKeys and < (Greater Than) in a Javascript function? Which event and which code (charCode Or keyCode)? I am very confused how to do this. I have read this link very carefully, Events and keyCode+charCode, but I could not find any solution for my scenario. ...

Strange bug in this time calculation script?!

Basically this script will subtract StartTime from EndTime, using a jQuery plugin the html form is populated with Start and End Time in the format HH:MM, an input field is populated with the result, it works except for one issue: If Start Time is between 08:00 and 09:59 it just returns strange results - results are 10 hours off to be pr...

Speed issues with a long script?

I write a lot of bookmarklets and I put them inside a meta-bookmarklet (>20kb so far) thus: var uGlY_vArIaBlE=(function(){ var d=document; var f1=function(){}; var f2=function(){}; … … /* lot of code here */ … var f50=function(){}; }); uGlY_vArIaBlE(); Is it okay for me to assume that f50 will 'know' that d=document as f...

Is it possible to use custom c++ classes with overloaded operators in QtScript?

Does anyone know if it is possible to have a C++ class with overloaded operators such as +,-,* and declare it somehow (this is where the magic happens) to a QtScriptEngine such that js-expressions like "a+b" are evaluated as they would be on the C++ side? ...

Relative mouse movement in HTML5.

I'm (still) porting an old Macintosh game to HTML5 and JavaScript. The game is a Tempest clone. (Wikipedia article on Tempest) (Shameless pimp of my project) While it's certainly possible to implement controls using the keyboard, I'm also wondering if it's possible to make relative mouse movement work in HTML5. The typical ways that I'...

If switching to adobe air will be a good move ?

I am web developer from a year.I have Used PHP,python with client side Js libraries like Jquery,motools, etc. So if switching to Adobe air will be a good thing ? If It is strong enough to make decent desktop apps (Eg: music/videos player)? If apps can be made for Android or iphone OS ? Can i use Jquery like libraries (i am very used ...

How to execute JS from Python, that uses 'Document' and/or 'Window'

I am currently working on getting JavaScript to execute successfully from within Python. I have implemented a JS engine (v8) using the PyV8 package. From here I can execute primitive JavaScript ("1+2", etc). However, for JavaScript that uses references to "document" or "window" the code will throw an error. I am looking, ideally, for a P...

Redirect Search results from google to a specific page.

HI, I have a specific requirement, when a user searches in google.com which returns me a list of results and one of the results is my website but it is pointing to a different page. I need help in 2 places, Client is planing to enhance my website so that what ever link of my website appears in google results should show as cars.com/s...

Rotate HTML with JS as in Photoshop's free transform

I need to rotate some html content (let it be a div) by dragging a block inside it with a mouse. The content should rotate around it's center. Look at http://www.polyvore.com/cgi/app (drag an element from right to left and drag a circle inside it) for an example. Are there any plugins or solutions in js to do it? Thanks in advance. ...