javascript

Any alternative to jQuery change() to detect when user selects new file via dialog box in IE8?

I am unable to detect when input type="file" changes its value after user selects file and the dialog box closes. $('.myInput').change(function(){ alert($(this).val()); }) Above jQuery code works perfectly in all browsers apart from IE. For some reason IE detects the change only after input field loses focus. Is there a way to d...

javascript parse parenthesis

I need parse a string inside a parenthesis, which looks like (A, B, C), where A, B, and C are string that can contain any legal JavaScript code. For example, B might be a very long string with nested structures similar to (A, B, C). What would be the best way to parse such a string? An example of the string to parser is invoking a fu...

JavaScript: 2 window.opener.location.href statements with alert() in between not functioning

I need to make a little JS app to scroll automatically through a list of URLs. I've chosen to have the functionality in a pop-up, for various reasons. The syntax to change the opening window's URL is: window.opener.location.href = "http://www.example.com"; This works fine with one URL, but if two statements are called, only one is e...

javascript switch using intervals

Can I use intervals in a switch statement? Like switch (parseInt(troops[i])) { case <10: editbox.style.fontSize = "13px"; break; case <100: editbox.style.fontSize = "12px"; break; case <1000: ...

"Intercepting" user input into text box and removing it

I have a text box that I would like to do some validation on. At the moment I have this code: function updateChanger() { // Validate input var likeMessage = validateInput($("#like").val()); alert(likeMessage); } function validateInput(input) { input = input.replace(/[^a-zA-Z0-9:\(\/\)\s\.,!~]/g, ""); return input;...

Return caret postion or range of a div in IE8

I am wanting to return the start and end range or the caret postion inside a div. The div will have the attribute contentEditable. typically I would use document.selection.createRange(); but the createRange function is broken in IE8 is there a way to get around this? ...

Bookmarklet, js injection and popup issue

I'm currently writing a bookmarklet that loads and executes a remote js file by appending a new <script> tag in the current window, like so : javascript:(function() { if(typeof __bml_main != "undefined") return __bml_main.init(); var s= document.createElement('script'); s.type= 'text/javascript'; s.src= 'http://127.0.0.1...

How to ignore uppercase/lowercase when selecting pathname? JS/Jquery

if (pathname == "/" || pathname == "/default.asp") in js using jquery library. I want this to catch "Default.asp" as well as "DeFaULT.asp" and "default.asp" halp. ...

How to alter the Browser's Refresh Event and trigger a custom function?

As you all know, when we hit the refresh button, the entire page starts to reload. But I dont that, I only want to refresh some portions, which need to be refresh in case of a need. I know, I can use ajax to reload a piece of content. But I want to attach this ajax function while the user clicks the refresh button or presses F5 or pres...

javascript how to display text when mouse over input text box?

How to display text when mouse over an input text box the simplest way (no css, or etc)?? ...

Slow Jquery Animation

I have this webpage : http://miloarc.pyrogenicmedia.com/ Which atm is nothing special. It has a few effects but none that break the bank. If you mouse over a tile, it should change it's opacity to give it a fade effect. This is done through the Jquery Animation, not through CSS (I do this so it can fade, instead of being a straight ch...

How do I provide an HTML embedded code for my web page?

I have a web page that I would like others to add onto their own web page. I know I can do this by providing an IFrame code, but is there a better way, such as providing a Javascript to embed? The IFrame has ugly scrollbars that do not make the embed so seamless. Can anyone help with this? ...

Google Maps geocoding (address to GLatLng)

I am trying to draw a geodesic polyline with Google Maps JavaScript API from two address points. var polyOptions = {geodesic:true}; var polyline = new GPolyline([ new GLatLng(), new GLatLng() ], "#f36c25", 5, 0.8, polyOptions ); map.addOverlay(polyline); if (GBrowserIsCompatible()) { map.addOverlay(polyline); } Could so...

IE7 - jquery addClass() breaks floating elements

I have this nav that uses addClass('hover') when the mouse is rolled over an item. This works fine except in IE7 when the addClass function is called every element with float:left stops floating and the page totally loses its structure. This is my JS: _this.position_sub_menus = function(){ $('#header #nav > ul > li').mouseenter( ...

Save jQuery callback functions in a separate file

Probably I missed something, but lets say I have this: $('a.delete').click(function(){ resp=window.confirm("Are you sure you want to delete this?"); if(resp) return true; else return false; } Now, I want to save that callback function into a separate js file, because I will use it in several pages. My logic told...

Is there a publicly available CDN that hosts JSON2?

It's well known that Google and Microsoft host several common javascript libraries on their CDNs (content distribution networks). Unfortunately neither seems to host JSON2.js. I'm aware that I could upload a copy of JSON2.js to my server and serve it myself, but there are a number advantages CDNs offer that I would like to take advanta...

jQuery: what is it "forbidden" to do in plain Javascript

A jQuery best practices question. I am writing a very jQuery intensive web page. I am new to jQuery and notice its power, but as I come with heavy javascript experience and knowledge, my question is: What should be done in jQuery and what in plain javascript. For example, there are callbacks that send a plain DOM object as an argument....

How to Access a DIV inside a iframe from a Parent

Hi, Hoping someone can assist but I am trying to access a div id="mnuGrp" that resides inside a child iframe(id="iframe2) from the parent window within the document.ready() section but unsure how to access this child div in the parent inorder to apply fadein and fadeout calls. Want to be used within the following call: $(' ???? ').cli...

Django, CSRF protection and js generated form

I have to create a form dynamically via javascript (yeah, that sounds ugly, but read this for the reason) and wants to make its submission CSRF proof. Usually, I use the @csrf_protect decorator in my views, and the {% csrf_token %} tag in my templates, as recommanded in the doc. But what should I do with a client-side generated form ? If...

TypeError: Result of expression 'printWindow' [undefined] is not an object.

I'm trying to create hidden iframes in my page dynamically to load 3 other pages so that i can grab all the HTML and combine them into 1 in a new window. However i'm stuck at this. tHe frames are created fine. But whenever the javascript runs to the part of var printWindow=""; function openNewWindow() { printWindow = window.op...