javascript

What is the jQuery equivalent of the Prototype function .activate()

Prototype's activate function Gives focus to a form control and selects its contents if it is a text input according to the Prototype website. i.e. $('my_element_id').activate(); What is the equivalent function in jQuery? ...

Iframe Scrollbar css

How do i go about changing the css of an iframe scrollbar? My problem with the current scrollbar in my iframe is the frame is not very wide and the scrollbar appears bulky in it and takes up too much space... Using "scrolling="no" makes the scrollbar disappear but then the user cannot scroll... By the way, My browser is Google Chrome... ...

Get Firefox mouse event on onbeforeunload when it doesn't exist???

Hi all, so the onbeforeunload event doesn't have mouse information, so how do I get mouse XY? I am trying to know if the user clicked the close buttom on the browser to log them out right away (20minutes of session is too long for resource, but, we will not shorten it to make customer angry). On IE, I can simply access mouse info to fi...

Notication bar similar to the one used by Stack Overflow

How do I write a notification bar in JavaScript similar to the one that you see on Stack Overflow? In my project they are asking for one just the same as this website and I'm looking to see how I go about coding one up. How can I write the code for this? Any suggestions? ...

where does SVG code go in relation to html, body, header, javascript, css

can you please give me a structure like this: <html><body><svg></svg><javascript>..............</html> ?? i am having A LOT of trouble adding css and javascript to an SVG file that looks like this: <?xml version="1.0" encoding="UTF-8" standalone="no"?> <svg xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativeco...

Examples of multiple instance javascript widgets (on same page)?

Apologies for the quick question, but I'd like to see some sample widgets that allow multiple instances in the same page. (Articles about this technique would also be good!) Digg's widget allows this (http://about.digg.com/downloads/widgets) but I don't know of any others. Do you? Thanks. ...

JQuery / JavaScript - trigger button click from another button click event

Hi I have this HTML which looks like this: <input type="submit" name="savebutton" class="first button" /> <input type="submit" name="savebutton" class="second button" /> and JS: jQuery("input.second").click(function(){ // trigger second button ? return false; }); So how can I trigger the click event from the 2nd button by cl...

Using document.write to load Google Libraries JavaScript API

I'm trying to use document.write() to load the Google Libraries JavaScript API. The following works (the alert pops up) in every browser other than IE. Please note that I replaced my actual API key with "MY_API_KEY" in the example below and that the script tag is broken into two strings to keep the browser from having parsing errors. ...

embedding javascript and CSS in an SVG

i have a map of the US: http://upload.wikimedia.org/wikipedia/commons/a/a5/Map_of_USA_with_state_names.svg i am trying to embed this code in it: http://sixrevisions.com/tutorials/javascript_tutorial/create_lightweight_javascript_tooltip/ as you can see it has CSS and javascript however, i am having a very diffficult time trying to p...

Can I use this code to set the height of two elements in jQuery?

I want to set both #map_canvas and #content's height, but this doesn't seem to work: $(['#map_canvas','#content']).css("height", ($(window).height()-270 + "px")); Does anybody know how to do this? ...

next() not working

Hi All, I have a table structure: <tr> <td> <a href="#" class="xx"></a> </td> <td> data </td> </tr> <tr> <td> <img src="#" class="cc" /> </td> </tr> <tr> <td> <a href="#" class="xx"></a> </td> <td> data2 </td> </tr> <tr> <td> <img src="#" class="cc" /> </td> </tr> Now, on load, 2nd an...

error on line 127 at column 19: AttValue: " or ' expected

i am getting this error on the last line here: <path d="M 909.99146,226.40625 L 911.86646,228.4375 L 914.05396,232.03125 L 914.05396,233.90625 L 912.02271,238.4375 L 910.14771,239.0625 L 906.86646,242.03125 L 902.17896,247.34375 C 902.17896,247.34375 901.55396,247.34375 900.92896,247.34375 C 900.30396,247.34375 899.99146,245....

Overriding a Javascript method only if it does not exist

My goal here is to override a method if it isn't found, otherwise use the original method (for backwards compatibility of a library I can't alter). This is what I have so far, but am still struggling with: this.grid.getDataSource = function(){ if (typeof this.grid.getDataSource.getDataSource == "undefined") return t...

Animating image/3D/sprite with javascript/css3/canvas

Kind of a dilemma here. I am making a mobile version of a website, that has some interactive things more specifically I have this object in 3D that you can spin, I was using papervision in Flash but now I need to do this differently since there is no flash in mobile and I feel I am on thin ice. I was thinking of exporting a 360 degree s...

dijit.form.select options list not scrolling in IE

I'm using the Dojo Javascript library and trying to add a Select component to my page for a list of states. It works great in Firefox, however, in IE when single clicking in the white area under the scrollbar slider doesn't work. The list moves back to the top. Here is a simple example: http://www.northpointgis.com/files/testdijiform2...

Simplest way to pass value back from anonymous callback?

I'm still trying to understand javascript scoping. What is the simplest way to return a value from an anonymous callback function? For instance, var test = 'outside'; callsFunction(function() { test = 'inside'; }); console.log(test); where callsFunction calls the anonymous function. I would like this to print 'inside'. ...

how to insert some markers (json format ) to map using google maps v3 .

i follow this article i find can use kmllayer to insert kml or georss , like this : var myLatlng = new google.maps.LatLng(49.496675,-102.65625); var myOptions = { zoom: 4, center: myLatlng, mapTypeId: google.maps.MapTypeId.ROADMAP } var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions); var georssLaye...

Javascript: Hide elements by class name

I have an html element that I want to hide from view, but I can't access that element by an ID because it has no ID and I can't assign an ID to it. It has a class assigned to it though. Is there any possible way to hide this element from view without having it's id? ...

How do I get Ajax request data with jQuery?

I have an Ajax request: $.ajax({ url: "MyPage.aspx", data: params, success: function(data) { // Check results $('#testp').append(data.message); enableForm(); }, error: function() { alert('Unable to load the permissions for this user level.\n\nYour login may have expired.')...

defineSetter in a loop

As a followup to http://stackoverflow.com/questions/3558240 I'm now having troubles with defining setters in a loop. This is the code that I'm attempting to use within a Greasemonkey script. var setValue_InStoredObject = function(_prefName, _varName, _newValue) { console.info('setValue_InStoredObject:\narguments = '); console.inf...