javascript

Injecting text when content is copied from Web Page

I ran into a a site that injects a "Read More: " line at the end of any text that you highlight and copy from it's pages. I've never seen this before, and without severely digging into their code, I can't find the code that does this. Anyone know how this is done? Example: http://peaceful-parenting.suite101.com/article.cfm/how_to_keep...

Good Cross-browser tri-state checkbox?

Hey guys, I'm looking for a nice tri-state checkbox controller in JS ? Got anything to recommend me? The states I'm looking for are Checked Unchecked Indifferent (Was never checked/unchecked) ...

jQuery - Replace Image, Retain Event Handlers

I currently have a jQuery function that replaces an image when clicked. For instance: <script type="text/javascript"> $('#test').click(function(event) { event.preventDefault(); img = $('<img id="myImage" class="photo" src="newImage.jpg>'); $("#myImage").remove().append(img); }); $('#myImage').click(function(event) { ...

slow down code until ajax function is over?

I want to call fillContent then later called beginEditingQuestion fillContent(cid, "questions"); beginEditingQuestion(qid); The problem is that I can't rung beginEfitingQuestion until all the ajax in fillContent is done. Is there an elegant way to delay the code? The only idea I can think of is to make a totally new function fillConte...

How do I keep a div in the center of the page?

I'm using jQuery to create a "dialog" that should pop up on top of the page and in the center of the page (vertically and horizontally). How should I go about making it stay in the center of the page (even when the user resizes or scrolls?) ...

How do I allow the user to move an absolutely positioned div?

I am using jQuery to create a "dialog" that should show up in the center of the page on top of everything and should remain centered at all times unless the user moves it. It has a header area (like a title bar) and I would like the user to be able to click there and drag the dialog "window" around. It is an absolutely positioned div. W...

Repositioning loading image

I have a loading image (gif) that shows up when a user is waiting for a response to an action on a ASP.NET page. The way it's implemented currently is: In a JS file, I have: document.write( '<span class="loadingbar" ID="loadingbar"><p>Loading Data... </p>' ); document.write( '<img id="loadingbarimage" src="Images/loading.gif" />' ); d...

JQuery JFlow - slideshow - cannot move 'left' 'right' buttons

I use JQuery to show N pictures in slide. So I put everything as needed, have to define two left/right links so user can scroll pictures. Problem is that JQuery engine automatically put those two on lower left and right corner of web page. Is there a way to tell JQuery not to do that, so I can position them where needed? How it looks...

Is it possible to detect when a JavaScript-opened window's location changes?

If I open a window with JavaScript (e.g., with window.open()), is there a way, using the handle on the window I opened, to be notified when the URL of the window I opened changes? For example, I'd like to be able to do something like this, generally: <script type="text/javascript"> function openNewWindowAndNavigateTo(url) { ...

Simple Jquery Dialog but now on click

I tried making a dialog using jquery it works but I have no succes at doing it onclick bacuse it should not just popup but only when you click on it. <script type="text/javascript"> $.ui.dialog.defaults.bgiframe = true; $(function() { $("#dialog").dialog(); }); </script> and <div id="dialog" title="Basic dialog"> <p>hi how a...

Appending a hash '#' symbol to url with a form action?

So I've got a form with a submit button and a text input... I want: http://localhost/ to become: http://localhost/#q= I did a solution in javascript which involves changing the "action" of the form to the url with the hash onclick.. but this doesn't work in IE. Anyone have a solution that works on all browsers? ...

How to pass a variable by value to an anonymous javascript function?

The Objective I want to dynamically assign event handlers to some divs on pages throughout a site. My Method Im using jQuery to bind anonymous functions as handlers for selected div events. The Problem The code iterates an array of div names and associated urls. The div name is used to set the binding target i.e. attach this event ...

Is there any analogue in Javascript to the __FILE__ variable in PHP?

Pretty straightforward, I've got a JS script that's included on many different sites and needs to have parameters passed to it. It would be useful if those could be passed via the URL, eg: <script type="text/javascript" src="http://path.to/script.js?var1=something&amp;var2=somethingelse"&gt;&lt;/script&gt; Yes, you can still pre...

Strange behaviour in IE7

Background I have a page coded in .Net 1.1 and it has two dropdown lists A & B. Any changes to dropdown A will change the number of items in dropdown B which has some sample Javascript behind it. The only complicated bit is that it has a 5.2 MB lookup file (the file contains Javascript but located in a aspx file) which is located in a ...

How to include two attributes with jQuery

I am new to javascript in general and pretty much have no idea what is going on. Sorry for the super noobie question. I have an accordion being started with the following code: $(function(){ $("#accordion").accordion({header: "h3"}); }); But I have no idea where to include autoHeight: false Any general javascript beginner's guide...

JavaScript object sub-class

I want to create sub-class B that inherits from super-class A. my code here: function A(){ this.x = 1; } B.prototype = new A; function B(){ A.call(this); this.y = 2; } b = new B; Console.log(b.x + " " + b.y ); when run it,it show B is undefined. ...

How to view the source of currently displayed html page(dynamically) than the original page?

G'day everybody, As an avid firefox user, I use plugins like stylish and greasemonkey to modify default styles of pages. However the view->page source option of the browser shows only the page in its original form and not the current form after it is manipulated by a script or a style. Is there any way i can view the source o...

How to search csv string and return a match by using a Javascript regex

I'm trying to extract the first user-right from semicolon separated string which matches a pattern. Users rights are stored in format: LAA;LA_1;LA_2;LE_3; String is empty if user does not have any rights. My best solution so far is to use the following regex in regex.replace statement: .*?;(LA_[^;]*)?.* (The question mark at th...

Why does the cursor keep jumping to the end of my TextFieldView while typing?

I have a sproutcore 1.0 page with SC.ListView items and a SC.TextFieldView bound to the same property of a model. When I type at the end of the TextFieldView everything works as expected. If I position the cursor in the middle and start typing the cursor jumps to the end. What could be causing this? I suspect that the jumping is happen...

jQuery plugin public method/function

Hello, I am trying to achieve something like the following but dont know whats wrong: $.a = function() { // some logic here function abc(id) { alert('test'+id); } } $.a.abc('1'); I tried using the return function, but that doesnt seem to work either. Can someone please help. Thank you for your time. ...