javascript

Browser behavior with huge doms

Can anyone speak to how the different browsers handle the following: Picture an HTML document essentially rendering content of a static app with lots of data. <div class="abundant_class"> <div class="abundant_class"> <div class="abundant_class"></div> <div class="abundant_class"></div> ... </div> ...

Can you detect/redirect a back button press through javascript?

I'm trying to detect and change browser behavior if a user clicks on the back button. Is this even possible through Javascript? ...

how to use variable in a variable name

hi so i am working with a json variable like this: opponentInvData.item1 it contains items 1 through 6 i need to access the different items dynamically and set them to null. itemNum is the specific item i need to access. im trying to use the eval function var itemNum = 2; eval(opponentInvData.item + itemNum + ' = ""'); needless t...

How to set jquery localScroll's offset dynamically?

jQuery(function( $ ){ var theOffset = ($(window).width()-900)/-2; $(window).resize(function() { var theOffset = ($(window).width()-900)/-2; }); $.localScroll({ target: '#content', // could be a selector or a jQuery object too. queue:true, duration:1000, hash:true, offset: ...

keydown Event to override return key does not work in Firefox

I have the following simple javascript code, which handles the Return Key, I don't want to submit the form when the return key is pressed in the textbox. All this works fine, but in Firefox, if i show an alert message, then it stops working and the form starts getting submitted, whereas the exact code without alert message works fine an...

How can I automatically start playing music upon entering of Konami code when visiting website?

Could someone help me create some javascript to perform the following behavior. Upon the entering of Konami Code while at a website (see:: http://files.www.gethifi.com/posts/konami/index.html for example), I want an mp3 to start playing in the background. I want to do this without any external library, such as jQuery. Thanks in advanc...

External javascript file not working

Hey there, I have some javascript that's loading just perfectly at the bottom of my site. I wanted to externalize this aforementioned js, so I'm now linking to the code externally, but now the code breaks and is pointing to an error (not within the js file but the jquery file). What changes when the js is externalized? Are variables re...

Make an entire <li> element clickable, but don't trigger the link when clicking inside links

I've been looking for a solution the last few days, I didn't really found exactly what I'm looking for. I have something like this: <ul> <li> <a href="http://www.link.com" class="li-url"></a> <h1>Title</h1> Lorem ipsum dolor <a href="http://www.something.com"&gt;Something&lt;/a&gt;. Etc, blah blah. </li> </ul> ...

Does an external .js file require <script> tags?

Does an external .js file require internal and containing tags to work? ...

Strange behavior of selection

My JS code: function getSelectedText(){ if(window.getSelection){ select = window.getSelection().getRangeAt(0); var st_span = select.startContainer.parentNode.getAttribute("id").split("_")[1]; var end_span = select.endContainer.parentNode.getAttribute("id").split("_")[1]; ...

Major bugs in SWFAddress

I found a couple of rather glaring bugs in SWFAddress, involving IE-based browsers. Both of the following occurred in SlimBrowser (15,000,000 downloads on Cnet) and one in Avant (also several million downloads on Cnet). Both bugs occur when returning to the original startup screen of a flex app via the back button. Both of them are rep...

jQuery - animate() properties

Hi I'm using jQuery's animate function like this: var css1 = { display: "block", marginTop: 20 }; var direction = "marginTop"; $(element).animate(css1, 150, 'swing'); Notice the marginTop property above. Well I want to replace that with the direction variable, but it doesn't work for some reason. Does anyone know w...

How to make a jsonp POST request that specifies contentType with jQuery?

I need to make a jsonp POST request with the content type 'application/json'. I can get the POST request to the server like this: jQuery.ajax({ type: 'POST', url: url, data: data, success: success, error: error, async: true, complete: complete, timeout: TIMEOUT, ...

tracking whether dynamic javascript files are loaded or not

I am loading javascript dynamically thru following. function loadjscssfile(filename, filetype){ if (filetype=="js"){ //if filename is a external JavaScript file var fileref=document.createElement('script') fileref.setAttribute("type","text/javascript") fileref.setAttribute("src", filename) } else if (filetype=="css"){ //if file...

Avoid go to link of block element while clicking on link inside

I have a LI element whith a link, and other links inside. It would be something like this: jQuery: $('li').click(function() { window.location = $(this).children('a.li-url').attr('href'); }); HTML: <ul> <li> <a href="http://www.link.com" class="li-url"></a> <h1>Title</h1> Lorem ipsum dolor <a href="htt...

Google Maps: How to create a custom InfoWindow?

I just came across http://fwix.com/ I really like how they create the InfoWindow (popup) when you click on a map marker because the corners on their InfoWindow are not as round as the default InfoWindow corners. Question: How do they create their InfoWindow so square, which I like, because the default Google Maps InfoWindow for a map m...

ANTLR - emitting multiple tokens for a lexer rule

Hi , I wanted to know if ANTLR supports emitting multiple tokens for a lexer rule, given the target language is JavaScript. I have found that it supports multiple tokens in other target languages, such as Java and CSharp, but could not find any documentation on this feature being supported in JavaScript. If anyone could point me to any...

Relative position in DOM of elements in jQuery

Given two jquery objects, Is there some way I tell which one is "further ahead" in the document tree than the other? In other words, with a document <p id="p1" ></p> <div id="div1"> <p id="p2"></p> </div> <p id="p3"></p> Is there some function that behaves thus? $("#p1").isBefore($("#p2")); // == true $("#p3").isBefore($("#p2...

Always return true in first call Returns correct value after first call

I am trying to find wheather exists in data base it always true returns on first attempt var IsEmailExistinInthemo = true; function EmailRegVerify(email) { var url = '/_service/setVerifyProfiles.ashx'; var pars = '&email=' + email; var target = 'output-div'; var myAjax = new Ajax.Updater(target, url, { method: 'get', par...

Handling multiple data objects in Protovis (javascript info visualization)

I am extremely frustrated with trying to prune and hand over to Protovis a set of arrays only containing numbers from a set of data objects that looks something like below to draw up three separate pie charts (pv.Wedge) for each object... myData = [{dept:"Accounting",sal:90000,equ:10000,trvl:267,extra:5000}, {dept:"Sales",...