javascript

JavaScript: Loading jQuery on Demand

What is the most lightweight way to include the jQuery lib into a page dynamically? I'm working on a page where sometimes it runs a few custom scripts (10 lines) and other times the entire jquery is also needed. ...

How to attach an event to onSubmit event of form with chaining earlier attached methods as well?

Actaully my application is having hundreds of pages. Now i have to attach an event 'disablePage' on onSubmit of form. I don't want to go to each and every page and write: <form name="frmname" onSubmit="disablePage();"> What i am doing right now is:- excerpt from common.js file; [ included in all pages ] /* we have to attach 'attachF...

Jquery broken by GetResponse (email marketing) web form script

I'm working on a site that relies on quite a bit of javascript. The problem is, I'm not a javascript guru in the least. Yes, bit off more than I can chew, here. I'm using jquery for a spy effect, and use GetResponse for email signups. If I implement my GetResponse script, it breaks the area later in the page which depends on the jquery...

Multiple document.write from external scripts

I have a URL that generates a document.write method that inserts another JS. Example: http://domain.com/scriptONE.js Generates document.write('http://domain.com/scriptTWO.js'); How can I use jQuery to insert the second document.write to a div not an iFrame - so that my div contains only the output from this file http://domain.com...

Dividing by infinity

I'm not a mathematician, but I assume dividing by infinity is either bad math, or, at the very least, impractical. I just spend a half hour debugging my javascript that was working perfectly fine in Firefox but was giving me an error in IE. I finally realized it was because in certain scenarios, I was asking IE to divide by infinity. ...

Fetching rendered JavaScript from a page (Omniture pixel)?

I have some code (incidentally, it is for Omniture SiteCatalyst) that renders a 1x1 pixel based on some JavaScript object variables I set in the page's source code. The JavaScript eventually creates an img based on the scripting code, but the img src isn't hard-coded into the HTML. How can I figure out what the img src is, given the URL ...

show javascript alert from controller's action in asp.net mvc

Is it possible to show a javascript alert message from controller's action in asp.net mvc(C#)? ...

Pass variable to JS file

Hello, Although this question have been asked and answered before, including on this website, I am not managing to solve my problem. I am using Masterpages, and Javascript files... and everyone now how "tricky" masterpages get with relative paths... Well, I am using a png fix called: unit Png Fix (quite good to be honest... even bette...

How to get jQuery Tablesorter to sort descending by default?

I can't figure this out. This question was also asked here http://www.nabble.com/TableSorter-plugin---default-column-sort-DESC-instead--How--to25180761s27240.html#a25180761 with no response. I've tried $.tablesorter.defaults.sortInitialOrder = 'desc'; and altering the jquery.tablesorter.js file to default to 'desc' but it doesn'...

Refreshing the main page after closing a modal window

Hello guys, On a given webpage I have a link that opens a modal window using Thickbox. In that window I have a form which I use to save some data. After I submit the form, I close the modal window. Now my question is: can I refresh the main page after closing the modal window? Thank you. ...

How do you undo "surroundContents" in javascript?

I'm writing a script that needs to move a wrapping node element around on the page. I find that when I do this, I remove the previously wrapped children. How do I unnest the children of a node, so that I can move that parent node elsewhere? I was thinking something like this: var parg = document.getElementById("blah"); if (parg.ha...

What is the Javascript method CollectGarbage()? When and why should it be used?

I notice in the VS2010 javascript intellisence there is a method called CollectGarbage(). Is this an IE only method? When should it be used? What are the advantages (or disadvantages) to using it? ...

Using JQuery to select some sibling elements

Hi all - I'm new to jquery and trying to accomplish something. My HTML looks like: <li> <div class="yes"><input type="radio" name="Group 1"></div> <div class="no"><input type="radio" name="Group 1"></div> Group 1 <ul> <li style="padding-left:25px"> <div class="yes"><input type="radio" name="Item 1"></div> <div...

How do I measure the strength of a password?

I was looking for an effective algorithm that can give me a righteous idea of how strong a password is. I found that several different websites use several different algorithms as I get different password strength ratings on different websites. ...

IE error with .options.length=0; or .setProperty('selected','selected') ?

Internet Explorer 8 and 7 fails with error when i update the select box with new option and choose the selected option. In other browsers this works fine and without errors. I use Mootools 1.2.3. <?php $getdestiny=$_GET['dest']; $getcountry=$_GET['countr']; print "<script type='text/javascript'> window.addEvent('do...

Totally basic Javascript reference question

The following in a Javascript console: var a = {'foo': []}; var b = {}; for (var key in a) { b[key] = a[key]; } a['foo'].push(1); console.log(b); Yields: Object foo=[1] I want to make a copy by value in b of each array for each key in a. Is there an easier way? ...

JavaScript/jQuery: Offset a <DIV> based on another <DIV> height after page load

Hi, I'm trying to do this: !!! just learned I cant submit images because I'm new... I have placed the image which perfectly describes the problem on Diino: Link to Diino folder (18,9kb) together with example files (html,css etc). The moving DIV has this CSS: div.linkr-bm { float:left; height:1px; overflow:visible; positio...

asp.net page location problem

I'm creating usercontrol. This control use javascript <script src='js/my.js' type='text/javascript'></script> My web directory location is here>> App_code\myusercontrol.css User\aa.aspx bb.aspx aa.aspx And bb.aspx is use my created usercontrol. My problem is when i calling aa.aspx, successfully work when i calling bb.aspx, javasc...

String prototype modifying itself

As far as i know it's not possible to modify an object from itself this way: String.prototype.append = function(val){ this = this + val; } So is it not possible at all to let a string function modify itself? ...

From within javascript, how can I load a script from another domain as a string?

I have an application which is written entirely as html/js (there is no server). Using javascript, I would like to retrieve a script from another domain and get its contents as a string. I do not want to evaluate the script. Is there any hack which can make this possible? ...