javascript

innerHTML W3C equivalent

im working with a cms made a few years ago in asp/vbscript (old asp) and until we release out dot net cms (should be soon) we are stuck with this one but at the moment im trying to make it a bit more w3c compliant ... currently our cms is IE only ... in the page editor you can switch back and forth from Preview state and html mode and ...

How can I Animate an Element to its natural height using jQuery

I'm trying to get an element to animate to its "natural" height - i.e. the height it would be if it had height: auto;. I've come up with this: var currentHeight = $this.height(); $this.css('height', 'auto'); var height = $this.height(); $this.css('height', currentHeight + 'px'); $this.animate({'height': height}); Is there a better w...

How to get scripts to fire that are embedded in content retrieved via the jquery load() method?

I have found several other questions here on S.O. (and the web in general) that ask roughly this same question, but the answers always seem to suggest other ways of structuring code that avoid the need for addressing this underlying issue. For example, many people suggest (and a good suggestion, I agree) to put your code in the jquery l...

Remove tag around a text node using javascript

If I have some HTML that looks like this: <div id="text"> This is some text that is being written <span class="highlight">with a highlighted section</span> and some text following it. </div> And I want to remove the "span" leaving the text node within, how would I go about doing that? I tried using jQuery to do the follow...

Implementing the "system" command in Java.

I have need for a "system" function call, the same as those in Python, Perl, PHP, Ruby, &c. It will be a component of a JavaScript standard library called Narwhal, when it's run on the Rhino JavaScript engine, which is in turn run on Java. The trouble is that Java's standard library appears to have abstracted away the ability to spawn ...

Silverlight exception not being handled with JS

I am debugging Silverlight 2 on Firefox. I get an unhandled error in firebug : Unhandled Error in Silverlight 2 Application Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED)) at MS.Internal.XcpImports.CheckHResult(UInt32 hr) at MS.Internal.XcpImports.GetValue(INativeCoreTypeWrapper obj, Depende...

prevent firefox reload when changing element position/size

i have a div which contains a flash object. the flash has a button that maximizes that object to the full height/width of the browser window[a sort full screen option but limited to the browser]. when ever the position[top,left] is changed it refreshes the content. because the flash object pushes data back and forth between the web app t...

ENTER key on a FORM with a single Input Field, will automatically SUBMIT with GET

Why is it that a form with a single input field will reload the form when the user enters a value and presses the Enter key, and it does not if there are 2 or more fields in the form. I wrote a simple page to test this oddity. If you enter a value in the second form and press Enter, you'll see it reloads the page passing the entered val...

Why does this setTimeout callback give me an error?

I am attempting to collapse a div on request, but my setTimeout function will does not successfully call its callback function. Here is the code below: function newsFeed() { this.delete = function(listingID) { var listing = document.getElementById(listingID); var currHeight = listing.offsetHeight; var confirmDelet...

javascript jquery bookmark changing

Hey SO, I get the feeling that this is impossible, but is there a way to change what the url of my page will be if someone bookmarks it. I ask because I'm running something in an Iframe, which isn't reflected in my URI. I was thinking maybe I could keep track of where the Iframe is in javascript, and then if they try to bookmark the p...

cfg.hover error with jQuery hoverIntent plugin

I am attempting to use the hoverIntent plugin to delay some animation effects on progress bars. However, for some reason hoverIntent doesn't seem to be functioning at all. I have the following in my page header (all paths have been verified): <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery....

check form on submit

I have a form with many fields and 2 submit buttons. I want to run a different check depending on which submit button i click on. I tried writing the code below but it is wrong (i dont know JS) and nothing happens (bad syntax?). How do i figure out which of the two buttons was clicked? document.getElementById('sub1').onclick = checkForm...

jQuery AJAX fires error callback on window unload?

If I navigate away from a page in the middle of an $.ajax() request it fires the error callback. I've tested in Safari and FF with both GET and POST requests. It has been suggested that one could abort all AJAX requests on page unload but the error handler is actually called first so it doesn't seem possible nor practical. This is pro...

Prevent loss of variables when browser reload button is pressed

Hi to everybody, Is it possible to keep my (global) variables when the page is reloaded? If yes, how? Thanks for any help. Best regards. ...

Rounding the result of division in Javascript

I'm performing the following operation in Javascript: 0.0030 / 0.031 How can I round the result to an arbitrary number of places? What's the maximum number that a var will hold? ...

jquery getJSON IP

I am trying to convert the following code to work with jquery: var req = new XMLHttpRequest(); req.open('GET', 'http://jsonip.appspot.com', true); req.onreadystatechange = function (e) { if (req.readyState === 4) { if(req.status === 200) { var ip = JSON.parse(req.responseText); alert(ip.address); ...

jquery load issue

Hi, I'm loading pages asynchronously with the jQuery load function, like this: tree.click(function() { if ($(this).hasClass("file")) { tree.removeClass("selected"); $(this).addClass("selected"); content.load("content/"+this.id+".html"); cont...

How to find out the server ip address (using javascript) that the browser is connected to?

Is there any way you can find the ip of the server that the browser is connected to? For e.g. if the browser is accessing http://www.google.com, can we tell in any way what ip it is connected to? This is very useful in cases where DNS round robin is implemented. So say, the first request to a.com results in 1.1.1.1 & subsequent request r...

How to detect when one function is complete from another function?

I have a javascript function that is being built to animate the collapse of a div, and then proceed with other jobs. The code is as follows: function newsFeed() { var self = this; this.collapse = function(listingID,orig_height,curr_height,opacity) { var listing = document.getElementById(listingID); var reduceBy = 5;...

String concatenation vs string buffers in Javascript

I was reading this book - Professional Javascript for Web Developers where the author mentions string concatenation is an expensive operation compared to using an array to store strings and then using the join method to create the final string. Curious, I did a couple test here to see how much time it would save and this is what I got - ...