javascript

Good PHP Text Pagination

Hi folks, First post here. I'm working on an information warehousing site for HIV prevention. Lots of collaborators will be posting articles via a tinyMCE GUI. The graphic designers, of course, want control over page lengths. They would like automatic pagination based on the height of content in the page. Anyone seen AJAX code to m...

Finding in a predefined set of text options

Say, I want to see if a DOM element is a block. I can write it in three ways, depending on my mood: // first way if (el.currentStyle.display == "block" || el.currentStyle.display == "inline-block" || el.currentStyle.display == "table-cell") // second way var blocks = {"block": 1, "inline-block": 1, "table-cell": 1}; if (el.curre...

ASP.NET Request - Can I get a posted file from a dynamic control created on client?

Hello, I have a web control with some custom javascript. The javascript creates new file upload controls on the client dynamically using code similar to: var newFileUpload = document.createElement('input'); newFileUpload.type = 'file'; container.appendChild(newFileUpload); // where container is a div This exists in an ASP.NET form wi...

Synchronous GET request with YUI 2.7?

hi, i'm relatively new to YUI - browsing their great docs, i do not find a method or a flag to load an external resource synchronously. or the question the other way around; for each matched node i need to call a method, which inserts something at the node; with asynchronous calls the remembered identifiers seem to mess up. therefore...

online Javascript code evaluation tools

Do you have a favorite site or homegrown page in your toolbox to help you during development of your Javascript? Something to help you: validate run debug, inspect unit test Looking for somewhere to paste my JS into, click a Run button, and have it evaluate the statements. This might be for simple snippets for manipulation of numbe...

jQuery height() problems with Internet Explorer 6

I'm using jQuery 1.3.2. I'm having trouble getting a correct "height" in Internet Explorer 6. Height values are correct in all other browsers. I am also using wresize jQuery plugin. Each time the browser loads, I fire a method that resizes divs, iframes based upon browser dimensions. (There's a good reason for this.) The returned v...

Make DIV accept and handle drop via JavaScript possible?

I've been googling and trying this for a good while now, but comes nowhere. So here goes: What I want to do is to drop text on a DIV tag and handle that with JavaScript. Something along these lines: <script type="text/javascript"> function handleDrop(sender, args) { $('#theDiv').html(args.textfromdrop); } </script> <div id="theDiv...

Why does this.selectedIndex not work on IE7 for a <select> tag?

This bit of HTML and Javascript works in IE6, FF2 and FF3. I can't find any reason why it shouldn't work in IE7 also, but this.selectedIndex always returns 0. ** in javascript file function onTypeChange() { alert($('type_id').selectedIndex); if ($('type_id').selectedIndex != 0) { Element.update('chosenType', this.o...

Google Maps - Thousands of markers - JSON

In the following example the markers are loaded from a JSON. If there are 20,000 markers the JSON is going to be quite big. Is there any way to send different JSON files according to zoom level instead of sending one huge array? http://gmaps-utility-library.googlecode.com/svn/trunk/markermanager/release/examples/weather_map.html ...

Clear/Remove JavaScript Event Handler

Greetings all - Given the following HTML fragment: <form id="aspnetForm" onsubmit="alert('On Submit Run!'); return true;"> I need to remove/clear the handler for the onsubmit event and register my own using jQuery or any other flavor of JavaScript usage. Anyone know how to do this? Thanks - Jordan ...

Hiding Extra Items in a list using jQuery in a tricky situation (markup is not ideal)

I want to make a long list short by hiding some elements in long sub-lists without adding extra processing on the server side. The problem is that the markup that comes from the server is not controlled by me and is not designed in a way to make my job easy. here is the code <ul id="long-list"> <li class="item"></li> <li class="item...

How to test an AJAX application that is pulling data from a live website?

Hello, I'm working on a AJAX application that pull data from a live website, I can't replicate the complete application on my local environment at the moment so in order to test if the Javascript code is working as expected I need to be able to bypass the same domain restriction on the browser (without making changes on the web server) a...

Why this unbind doesn't work ?

I try to answer this question a few minutes ago and prepared this example for myself : <script> function trialMethod() { alert('On Submit Run!'); return true; } function trialMethod2() { alert('On Submit Run trialMethod2!'); return true; } </script> <form id="aspnetForm" onsubmit="trialMethod();"> <input type="...

Eliminating redundant code in a jQuery script

I've set up a page to load data via AJAX, utilizing the jQuery .load function. Upon loading each new file by clicking a link on a tab bar, I'm using jQuery to set the selected tab's color to yellow. I tried using a .toggleClass function to set the class of a li element to active, so that it would be yellow, but no dice, so I've resorted...

How do I validate a javascript?

Hi, I'm using a small snippet of JS to add a presentational element to my blockquotes (As seen here): <script type="text/javascript"> $('blockquote.message').append('<span class="arrow" />'); </script> But the W3C validator hates that crap: document type does not allow element "span" here What am I doing wrong? Is there a way...

How do I add target="_blank" to a link within a specified div?

so lets say i got these following codes <div id="link_other"> <ul> <li><a href="http://www.google.com/"&gt;google&lt;/a&gt;&lt;/li&gt; <li><div class="some_class">dsalkfnm sladkfm <a href="http://www.yahoo.com/"&gt;yahoo&lt;/a&gt;&lt;/div&gt; </li> </ul> </div> so in this case script will add target="_blank" to all links within "link_...

How to trigger Google Analytics from code?

My app reads an (html) file from my website, and I would like to track accesses to that file using Google Analytics. As the GA Javascript does not get executed when reading the file, it is not tracked. Is there a way to trigger GA directly from code or alternatively, to execute the Javascript from a .NET app without adding a bunch of dep...

How to stop javascript alert from showing after pressing ok

I want to show an alert if I have something in my Facebook inbox. I think it can be easily accomplished using userscripts... this is what I have so far (thanks to the guys at the userscripts forums): document.addEventListener("DOMNodeInserted", function() { var count; if ((count=parseInt(document.getElementById("fb_menu_inbox_unread...

How to remove existing class name and add a new one with jQuery and Cookies?

How can you remove a class name and replace it with a new one. <style> .red {background-color: #FF0000;} .green{background-color: #00FF00;} .blue {background-color: #0000FF;} </style> <body class="red"> <ul> <li><a href="">red</a></li> <li><a href="">green</a></li> <li><a href="">blue</a></li> </ul> </body> In this case when you click...

Convert 4 lines of Jquery to Mootools

Hi, The following lines of code do two things. The first two lines add classes to the siblings immediately before and after an element with a given id (in this case a UL with id "nav") The last two lines add the classes first and last to the first and last sibling elements whose parent has the id "nav". This is jquery. How would I ach...