javascript

How to avoid navigate back when the user types backspace on a HTML text input?

Backspace is the browser hotkey for Navigate Back To The Last Page. I know that when an input has the focus this hotkey is disabled. But I have keyup and keydown events binded to this input, and something I wrote is causing this trouble. Do you know the solution? ...

How can I position a label inside its textfield?

I have many textfields that show instruction text within the textbox (how the default value would look). On focus the color of the text becomes lighter, but doesn't go away until text is entered. When text is erased, the label returns. It's pretty slick. A default value doesn't cut it, because these go away onfocus. I have it working, b...

Javascript Reference Comprehension

I have been learning some of the more detailed loopholes of JS here and there, and have a few things I need to get help on. ;(function($){ $.fn.makeRed1 = function() { return $.each(this, function() { $(this).css('background-color', '#FF0000'); }); } })(jQuery) ;(function($){ $.fn.makeRed2 = fun...

How to write a regular expression for this scenario?

For example, I have a string : /div1/div2[/div3[/div4]]/div5/div6[/div7] Now I want to split the content by "/" and ignore the content in the "[ ]". The result should be: div1 div2[/div3[/div4]] div5 div6[/div7] How can I get the result using regular expression? My programming language is JavaScript. ...

Cross Domain JavaScript parent location setting firefox error

Here is the case: page A contains iframe B, B contains iframe C, A and B are under the same domain, C under another. C tries to reset parent B's location with extra information following "#" to solve cross domain communication using Fragment Id Messaging. IE6/7/8 just works fine with this case, while Firefox blocks parent.location settin...

tinymce embed problem

Hi all, currently i am working on few tinymce plugins. in one of my plugin insert to embed flash swf. but it didn't work perfectly. its change the embed tag. here is the code: function insertMp3() { var v = document.getElementById('codebase').value+document.getElementById('file').value var html ="<object classid='clsid:d27cdb6...

Why does my setTimeout speed up when I have multiple tabs open to my site?

I have a timer that counts down every second. It works great until the user opens up 3 or 4 tabs of the my site, at which point the newest tab's timer goes double or triple speed. I can currently only reproduce the bug in IE8. I was previously using setInterval, and could reproduce the bug in Firefox as well. I'm actually using FBJS (...

Accessing a inner div value in javascript, with no ids to help

I have following structure <div onClick="javascript:Myfunction('value');"> <div title="Mytitle"> </div> </div> Can I access in the javascript Myfunction, the title of the inner div. There are no ids here. ...

removing duplicate script from page

I am trying to make use of the yahoo exceptional performance rule : avoiding duplicate script To do so i would like to be able to know whether or not a script was already added to the page before injecting it in the page. It looks like i can't figure what has been added in asp.net code behind unless i have a scriptmanager added to the p...

Catching applet exceptions in Firefox

In IE in the ff. code, the catch clause is entered if someMethodThatThrowsExceptions does throw an exception. However, this is not the case in Firefox. Is this a limitation in Firefox's Javascript engine or LiveConnect implementation? Does a workaround exist? try { document.applets["someApplet"].someMethodThatThrowsExceptions(); } ...

Questions about Javascript injection

Hi I been reading on asp.net mvc learning site about JavaScript injection and man it is an eye opener. I never even realized/thought about someone using JavaScript to do some weird ass injection attacks. It however left me with some unanswered questions. First When do you use html.encode? Like do you use it only when you are going t...

Javascript Popup window in IE6 and above...

I'm opening a modal dialog for IE6 and above using the following javascript. window.showModalDialog( 'SelectUser.aspx', null, 'status:no;dialogWidth:500px;dialogHeight:220px;dialogHide:true;help:no; scroll:yes;toolbar:no;title:no;resizable:yes;location:no;menubar:no;' );...

ajax request with prototype returns 200 success with blank html page (intermittent)

i have a page performing the following ajax request when a button is pressed. normally i get a json object back and it works fine, i have noticed on intermittent requests (usually only the first request from that page), i get back a 200 success code with a blank page. if i reload the html page, then press the button again it works fi...

jquery javascript module architecture on a website

I want to write a module on one html site - I will never leave the site I think about two possible concurrent basic approaches: We go into the module by use only a specific function (with specific params - everything which will happen, happen there - logic, exception handling etc) We go in by using one handler-fct, which manages some ...

Problem with jquery in IE8

I have the following code which opens and closes a specific div when a button is pressed using jquery I did not use toggle as I also needed to close all the other divs in the same group. $("#login-link").click(function(){ if ($("#login").is(":visible")){ $("#login-link").attr("src", "resources/images/menu/login.gif"); $(...

JavaScript causing "A script on this page may be busy, or it may have stopped responding." error in Firefox

I wrote a page by javascript that has over 1000 lines of code and so the page is so heavy. when i run the page on the firefox, it tell me that: A script on this page may be busy, or it may have stopped responding. You can stop the script now, or you can continue to see if the script will complete. Script: http://localhost:5070/resource...

How to come out from nested ajax

Hi, I have a tightly coupled javascript, where in there are series of if-else checks and multiple ajax calls are made. The ajax calls are nested type. My problem is I am in a deep nested ajax callable function and I want to get out from there gracefully. The snippet of the code is . function showSubscriptionLightBox() { $.get("/ajax...

String data passed to Java Applet by javascript is null when in Java applet

This question may look familliar but I've discovered some rather more pertinent information and tried some other things (which are detailed below) so to avoid confusion I've created another question. Here's the JavaScript (on an aspx page): function CallApplet(clientRef, system, branch, category, pdfXML) { AppletReturnValue...

Regex replace string but not inside html tag

I want to replace a string in HTML page using JavaScript but ignore it, if it is in an HTML tag, for example: <a href="google.com">visit google search engine</a> you can search on google tatatata... I want to replace google by <b>google</b>, but not here: <a href="google.com">visit google search engine</a> you can search on <b>googl...

How to prevent external JS to block your site from loading?

Hi, how do I prevent slow loading external js files from blocking the loading process of the whole website (because the browser processes 2 requests only at a time)? Let's say I want to include the sharethis button but the server is encountering heavy load and needs to long to serve my request, how can I force the rest to load anyway. ...