javascript

jquery attr("onClick") - ie and ff

Hi, Using jquery, I'd like to get the javascript from an A tag's onClick attribute. <a href='#' onClick='alert("boo");' /> In Firefox: alert($('a').attr("onClick")) shows: alert("boo") In IE 6/7: alert($('a').attr("onClick")) shows: function anonymous(){alert("boo");return false;} How can I retrieve just the javascript, and not the...

Writing to the DOM on body onload not working in Google Chrome

Hello. In Google Chrome, the following code snippet: <html xmlns = "http://www.w3.org/1999/xhtml"&gt; <head> <title>Example</title> <script type = "text/javascript"> <!-- function onBodyLoad() { var x = 42; document.writeln("x = " + x); alert("on load"); } --> <...

Problem with multiple actions onclick

I have a page with a form and navigation links. If you click on a navigation link I need to submit the form as well as follow the navigation request. To do this I have a link who's href is pointing to the new page request and I have the onclick event bound to a function that submits the form on the page. Could this scenario cause hard...

Browser support for <script async="true" />?

Today Google announced the support for asynchronous Google Analytics tracking. The asynchronous tracking is achieved using the async directive for the <script> tag. Which browsers support the async directive (<script async="true" />) and since which version? ...

Using JavaScript to dynamically swap show/hide and add active classes to anchor links?

Here is my scenario. I'm am HTML/CSS guy, JavaScript not so much. But this is a JavaScript problem. I'm building out a new resume site for myself; http://banderdash.net/design/ pardon the typography, I have yet to bring in Typekit and really get the look 'singing'. In a perfect world, I would have a script that could perform the follo...

jQuery UI - I want to check if a resize event was triggered on a resizable div

I have two divs $('.list') and $('.content') side by side. $('.list') is resizable using jQuery UI resizable and $('.content') is bound to the alsoResize. The problem I am having is I need to know when the resizable event is triggered. .bind('change') or .bind('resize') don't work because resize is only for the window/frame and 'change...

jQuery iPhone Style Checkbox Events

I'm using the jQuery package located at http://awardwinningfjords.com/2009/06/16/iphone-style-checkboxes.html to convert my existing checkboxes to iPhone style checkboxes. The problem I'm having is that,after applying the jQuery/iPhone styles, my checkboxes' onclick events do not fire when the checkbox status changes. I need to be able t...

How does PivotalTracker.com update its view in real time?

I'm trying to build a view similar to PivotalTracker where there are a variety of rows in different buckets. There is some polling to the server because rows could be updated by other users while you're working on it and the page should update on its own without having to manually refresh it. I know how to poll the server and get updat...

Javascript behavior on page refresh

What is the expected behavior of Javascript when you do a soft refresh on a web page? I know that when you refresh a page, most web browsers will preserve values entered into form elements on a page. But it becomes harder to predict what will happen on a refresh when half of the page is dynamically generated. My question is a little ...

my ajax script gets processed all over again even after the server has already responded successfully

so I put this alert() message inside the process() function just for testing. and it gets called every after the response has been made by the server. the process() is the function being called via onclick. what could be the problem and how to get away with this? ...

Target='_blank' to show in new window, NOT new tab, possible?

How can I do this? In firefox the link opens in a new tab... I don't want users to have to set settings of their browsers for this... I want a pop-up to appear with contact-form whenever user clicks 'contact' on my main page. How should I do this? Thanks... ...

Best practice for semicolon after every function in javascript?

I've seen different developers include semicolons after functions in javascript and some haven't. Which is best practice? function weLikeSemiColons(arg) { // bunch of code }; or function unnecessary(arg) { // bunch of code } ...

JS DOM Objects and the Style Attribute

I have two sets of code: var holder = document.createElement('div'); var a = document.createElement('div'); a.style.float = 'left'; a.style.width = '90px'; a.style.height = '90%'; a.style.border = '1px dotted black'; var b = document.createElement('div'); b.style.float = 'left'; b.style.width = '90px'; b.style.height = '90%'; b.style....

[jQuery UI] Connected sortable lists

Hi, I'm working with connected sortable lists and need the ability to add an extra list, but it just doesn't work. I have an XHTML like this: <div id="content"> <div class="line"> <span class="element">1</span> <span class="element">2</span> <span class="element">3</span> </div> <div class="line"> ...

Javascript to grab last part of the document.URL?

I am trying to grab the last part of the current url: URL: http://example.com/test/action I am trying to grab "action". The URL is always consistent in that structure. But it may have some extra params at the end. This is in a rails app using the prototype framework. In rails it would be params[:id]. ...

Showing a div element dependent on if it has content

Hello, With jQuery I am trying to determine whether or not <div> has content in it or, if it does then I want do nothing, but if doesn't then I want to add display:none to it or .hide(). Below is what I have come up with, if ($('#left-content:contains("")').length <= 0) { $("#left-content").css({'display':'none'}); } ...

Is there an event that fires on changes to scrollHeight or scrollWidth in jQuery?

I'm using JQuery to design an application where the user can drag elements inside of a div that automatically adds scrollbars and expands the scrollHeight/scrollWidth as needed. I need to fire off an even when the scrollHeight and scrollWidth of the container div are changed. No, don't want to use the scroll event because 1) scroll doe...

Validating forms in HTML, PHP, and JavaScript

If I am defining a function in JavaScript at the top of my page that validates if the string entered in a form is (A-Z,a-z, or 0-9). And then I call that function when they submit it saying : onsubmit="return Validator(this);" If the function name is : function Validator(form) Why isn't it actually validating the string submitted w...

Google Maps Version 3 Remove directions markers

Is there any way to remove the markers that the directions put on the map? I have 4 locations that show on the map. A green arrow where the user is and 3 locations marked A, B, C. If I click on one it routes between the user's location and the marker. The problem is that google adds a new A & B marker to the map as the start and end o...

How to do a JavaScript HTML 5 Canvas image "page flip" like you commonly see in Flash?

Has anyone tried recreating the page flip effect with images like you commonly see in Adobe Flash with JavaScript and HTML 5's canvas tag? Are there any frameworks or JQuery plug-ins that do this type of effect? The page flip in Flash allows you to grab a corner of the simulated book page and flip the page like you would flip a real bo...