javascript

How much content being replaced with an AJAX call is too much?

I run into a common problem when trying to do AJAX development. Where possible, I like to try and just update data in an existing layout, and not the layout itself. For example, take the div below: <div id="content-5">Here is some content</div> I would get the updated value for content-5 from the server and just replace the contents o...

Why does FF3 say "Permission denied to get property HTMLDivElement.tagName" ?

When I run this through FireFox 3: <script type="text/javascript" src="../resources/dojo-1.2.3-src/dojo/dojo.js" djConfig="parseOnLoad: true"></script> <script type="text/javascript" src="../resources/dojo-1.2.3-src/dojo/dijit.js"></script> <script type="text/javascript"> dojo.require("dojo.parser"); dojo.require("dijit.InlineEditBox"...

jquery behaves strangely in some sites when inserted via bookmarklet

I'm putting together a bookmarklet that inserts jquery into pages it is invoked on. On many pages it works just fine, but on pages like http://www.cnn.com (which includes both prototype and scriptaculous) it behaves a bit strangely. $(blah..).appendTo("body") does not work whereas $(blah..).appendTo(document.getElementsByTagName("body")...

How do I check a checkbox with JQuery or Javascript?

I want to do something like this $(".myCheckBox").checked(true); or $(".myCheckBox").selected(true); Is such a thing built into JQuery? To clarify, I wish to set the value. ...

How do I launch a specific telnet-based app from a web browser?

What I'd like to do is provide a link on an intranet web page that will launch a telnet session and pass context information to a shell script that will take the user to a specific "green screen." This "pseudolink" might help show what I'm looking for: <a href="telnet://<user>:<password>@<host>?showdetail%20123">detail for 123</a> ...

CSS/Javascript to force html table row on a single line

I have an HTML table that looks like this: ------------------------------------------------- |Column 1 |Column 2 | ------------------------------------------------- |this is the text in column |this is the column | |one which wraps |two test | ---------------------------------------------...

Javascript Fibonacci nth Term Optimization

I've become interested in algorithms lately, and the fibonacci sequence grabbed my attention due to its simplicity. I've managed to put something together in javascript that calculates the nth term in the fibonacci sequence in less than 15 milliseconds after reading lots of information on the web. It goes up to 1476...1477 is infinity a...

javascript race condition

I'm calling a javascript function that sets the opacity of an iframe an unknown amount of times in rapid succession. Basically this tweens the alpha from 0 to 100. here is the code function setAlpha(value) { iframe.style.opacity = value * .01; iframe.style.filter = 'alpha(opacity =' + val + ')'; } My problem ...

Can I suppress the browser’s login prompt on 401 response when using XmlHttpRequest with Twitter

I'm using jQuery's ajax methods to interact with the Twitter REST API. Their API is a bit annoying, in that some actions will return a 401 HTTP status code. In that case, I just want it to fail, instead of displaying a login box. I've tried just providing an incorrect user:pass pair in the URL, in case that might suppress the dialog a...

How do I make a "limited-fixed" div using HTML and JavaScript?

Given the existence of other divs on a page, how would one create a div that acts as if it's fixed-width within a certain domain of a web page? Example: the commenting system on Slashdot, which acts like a fixed-width div for purposes of scrolling along a screen but will remain within a certain length? I want a block of text to appear al...

Javascript Drag and Drop Grid

Hello, I'm looking for a script that would allow me to have a grid of draggable divs (used to organize image thumbnails). So when one div is dragged over another, the divs would shift to create an empty spot to drop the div. I know jQuery has a drag and drop lib, but it doesn't seem to allow for the functionality I need (snapping to a g...

Can I just make up attributes on my HTML tags?

Am I allowed to add whatever attributes I want to HTML tags such that I can retrieve their value later on using javascript? For example: <a href="something.html" hastooltip="yes" tipcolour="yellow">...</a> If that's not going to work, how would you store arbitrary pieces of information like this? Edit: Since it appears that making up...

How to get jQuery to pass custom arguments to asynchronous AJAX callback functions?

My page deals with many "Store" objects, each of them has a field called 'data'. However, this data is fetched via AJAX requests which may be parallely going on. function Store(id){ this.id = id; this.queryparam = 'blah'; this.items = null; } Store.prototype.fetch = function(){ $.get("/get_items",{q:this.quaryparam},fun...

Programmatically open new pages on Tabs

Hi, I'm trying to "force" Safari or IE7 to open a new page USING A NEW TAB!. Sorry, It seems like an impossible task :( Programmatically I mean something like: window.open('page.html','newtaborsomething'); Thanks! ...

Browser version Detection

I have a spec in my current project that requires us to advise the user which browsers are best to use the web application. If their current browser version they are using is not in our list of "ideal" browsers we want to display a message. What is the best way to check a specific version of the users browser. I am aware of the follow...

Lazy Load External Javascript Files

I am trying to write a javascript class that loads script files as they are needed. I have most of this working. It is possible to use the library with the following Syntax: var scriptResource = new ScriptResource('location/of/my/script.js'); scriptResource.call('methodName', arg1, arg2); I would like to add some additional syntactic ...

JavaScript (via Greasemonkey) failing to set "title" attributes on <a> tags

I have the following (fairly) simple JavaScript snippet that I have wired into Greasemonkey. It goes through a page, looks for <a> tags whose href points to tinyurl.com, and adds a "title" attribute that identifies the true destination of the link. Much of the important code comes from an older (unsupported) Greasemonkey script that quit...

Toggle data display inside table cell

I have a table that's generated by a normal PHP loop. What I want to do is create a form in the first column of each row that's hidden by default but appears when you click a toggle link in that row. I can make a normal toggle-able div by creating a CSS id called hidden and setting display: none;. Unfortunately I can't keep creating...

Calling javascript function inside JQuery

Dear all I am using javascript and jQuery My Mainfile has My.js,and ajax. My.js has function build_one(){ alert("inside build_one"); } My Mainfile has <script type="text/javascript"> .. // here I want to make call function defined in My.js build_one() .. ...

Pure Javascript YAML library that supports both dump and load?

Does such a thing exist for YAML (aka YAML)? If this existed at one time, it must have been obliterated because the latest search turned up nada. It looks like there are plenty of implementations that dump from Javascript to YAML output only, but having trouble finding an implementation that supports both dump and load. Is anyone worki...