javascript

jQuery: how to change tag name?

jQuery: how to change tag name? For example: <tr> $1 </tr> I need <div> $1 </div> Yes, I can Create DOM element <div> Copy tr content to div Remove tr from dom But can I make it directly? PS: $(tr).get(0).tagName = "div"; results in DOMException. ...

Ajax: Change responseText font color based on result

Hi. Programmers here have been extremely helpful in resolving issues for me in the past, so I thought I'd ask an Ajax question. It's probably a simple fix, but I'm new to Ajax. What I'd like to do is change the style of the responseText to red if the result is the pharase, "NOT FOUND". Otherwise the text will be black. Here is the scr...

Copy to Clipboard in Chrome Extension

I'm making an extension for Google Chrome and I have hit a snag. I need to copy a readonly textarea's content to the clipboard on click in the popup. Does anyone know the best way to go about this with pure Javascript and no Flash? I also have jQuery loaded in the extension, if that helps any. My current (non-working) code is... fu...

How to bind jQuery events on multiple PREDECLARED jQuery objects

Hi, This is how to bind multiple events on a couple jQuery selectors: $('#selector1,.selector2').bind('event', function (e, ui) { // Stuff }); But! How do you bind on predeclared jQuery objects. Example: var jSelector1 = $('#selector1'); var jSelector2 = $('.selector2'); Because, the following doesn't work: jSelector1,jSelec...

HTML Drop Down List Best Practices

Hey, I'm putting together a fairly simple HTML/Javascript/PHP form (I am fairly new to all of these). One field of the form requires users to select an option from a reasonably long list (using a drop down list). The contents of the list are extremely unlikely to ever change. Is there a "better" way to populate the list than simply usi...

Google Chrome Cookies - Broken for Virtual Hosts?

Hi.. I recently moved my development environment to my local machine (mac), and setup an Apache virtual host: dev-mysite so in the browser it's: http://dev-mysite/ No .com or anything like that issue I'm having now is that signing into the site requires setting a cookie and for some reason Google Chrome isn't letting my dev enviroment ...

Need advice on how to better code this function for frequent re-use and adding new functionalities

Hi, I need help to better simplify this process. In order to fully comprehend how everything fits together please refer to my previous post - My Web based system Basically, I want to send more commands to this procedure that I have written. Write now there is only one function I have implemented, detect, but I want to add more in the fu...

Colour transition JavaScript

I've noticed a site that seems to have a very nice colour transition effect on the background. When a link is pressed the background changes colour, however it doesn't seem instant. A transition seems to take place.. http://fuelbrandinc.com/#/about I was wondering if anyone had any idea how to replicate this functionality? Thanks, ...

Load URL + JavaScript action

Hello, I'm trying to get my users to download "maps" from bungie.net from my website. Example map: http://www.bungie.net/Online/Halo3UserContentDetails.aspx?h3fileid=31604914 Link users need to click to download map: <a id="ctl00_mainContent_xboxDownloadButton" href="javascript:__doPostBack('ctl00$mainContent$xboxDownloadButton','...

Where can I find an example of a large JavaScript project using Crockford's method for prototypal inheritance?

I have read about Crockford's push for using JavaScript in a more obviously prototypal manner (cloning objects to create new ones, never using the "new" keyword). But in the wild, I have never seen anybody use this style for larger projects. Where can I find examples of a large project that uses this style? ...

Baffling JavaScript Inheritance Behavior

<disclaimer> What follows is the fruits of a thought experiment. What I'm doing isn't the issue; the symptoms are. Thank you. </disclaimer> I've finally wrapped my head around constructors, prototypes, and prototypal inheritance in JavaScript. But the SomethingSpectactular method in the sample below bugs me: function FinalClass() { ...

How to detect a specific build of webkit in a client browser?

Because of WebSocket protocol changes in WebKit nightly build r59903, I need to know whether I should run additional scripts. That depends on WebKit build number. I'm using jQuery as a platform, so assume $.browser.webkit is true. Then how do I check whether client WebKit build is 59903 or higher? $.browser.version tells something like 5...

Using a progress bar to load a time-consuming script asynchronously

Hey guys, I'm loading a dynamic application (which takes 20-30 seconds), and I'm trying to create a dynamic progress bar that shows the user how much of the task has been completed dynamically as the page loads. I'm accomplishing this by setting buffer to false and having my script output a line of JavaScript as it progresses that call...

Displaying Google's 'directions' box on a map

I'm implementing a Google Map on a website. One requirement is to display a directions box, which contains the same fields as the one Google Maps uses, and which pops up when the user clicks a button. I'm aware that the Google Maps API allows you to draw a line between two different locations. Is it possible to display the directions ...

i have a question about jquery, i can't get DOM event, when i insert a new code to html DOM.

like this <html> <head> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"&gt;&lt;/script&gt; </head> <body> <div id="test">321</div> </body> <script> $(document).ready(function(){ $("#test").click(function(){ $.ajax({ url:"http://address/", type:"po...

Help with using JSON object inside PHP?

I am (trying) to build a web app, first one :) I need to call a JSON object though, and I am using a simple search form to get a word that I will append to the call, but I need PHP to handle the object when it is returned. How can I do this? Basically I had the form submit calling a function that, ideally, would go get the object and do ...

Is there a way to discern an iPhone 3G/S visitor to an iPhone 4 visitor?

I want to load higher resolution pictures for iPhone 4 users, but the only way I know of detecting users is by a user-agent. But I'm under the impression that the user-agent of MobileSafari on any iOS4 phone is the same across the board. What could I do to detect an iPhone 4? ...

find out which form does the clicked item belongs from

I have a series of forms in my html, the intention is that when the user clicks on the "continue" button, the current one disappears and the next one shows up. However I was wondering if there is a way of getting which "continue" button was pressed (that is, of which form) so to just have a piece of code that basically checks and hides t...

Ruby Hpricot RegEx replace <BR>'s with <P>'s

Can someone please tell me how to convert this line of Javascript to Ruby using Hpricot & RegEx? // Replace all doubled-up <BR> tags with <P> tags, and remove fonts. var pattern = new RegExp ("<br/?>[ \r\n\s]*<br/?>", "g"); document.body.innerHTML = document.body.innerHTML.replace(pattern, "</p><p>").replace(/<\/?font[^>]*>/g, ...

Regex pattern match small issue with brackets in pattern match

Hi There Someone helped me earlier with this regex: checkxls = checkxls.match(/'[^']*'(?:, '[^']*'){13};/g); The purpose is to capture a exact patter like this '', '', '', '', '', '', '', '', '', '', '', '', '', ''; Now I want to do the same thing but just with a pattern like this ('.*?', '.*?', '.*?', '.*?', '.*?', '.*?', '.*?',...