javascript

Getting offsetTop of element in a table

Hello, I can't seem to figure out how to get the offsetTop of an element within a table. It works fine on elements outside tables, but all of the elements within a table return the same result, and it's usually at the top of the page. I tried this in firefox and chrome. How do I get the offsetTop of an element in a table? thanks! ...

Call one function from another function in javascript

Hi I'm still a novice with web technologies and I have a few questions in line with the following code. I'm trying to call a function getDetails() from another javascript function displayTable(). displayTable() gets invoked on clicking the button 'My CD Facts'. Well, its not working for me. I guess its some thing daft but I'm not abl...

Getting the width/height of the entire browser in IE?

Does anybody here know what the Javascript call is to get the width/height of the entire browser window (including nav, menu, etc?) I know there is outerWidth, outerHeight in FF, Safari and other browsers. ...

Assign Excel Range to a Javascript Array

I'm working on some code to export a DataTable to Excel, and I'm trying to make it as fast as possible. Right now, I'm looping through each row and each column for each row (nested for loops). When I've got a large DataTable, this process can take some time. Can I assign a range of cells to an array in Javascript instead of looping throu...

correct way to echo a link with a onclick javascript function

Hello, my question is how I can echo this the right way because the variable in the onclick function gives out a undefined error $openchat="<a href='javascript:void(0)' onClick='return chatWith(" . $livenaam .")'>" . $livenaam . "</a><br>"; echo $openchat; I want to use it in a loop to get a list off users online for the chat Thank...

What is a good stand-alone JavaScript formatter for fixing missing semicolons?

I'm trying to retrofit/fix lots of legacy web code and unfortunately most of it is poorly formatted JavaScript. I'm looking for a batch/scriptable utility that can fix JavaScript that is missing simicolons at the end of executable statements. I've tried the beautify-cl.js script with Rhino but that does not does not add semicolons. In...

Allowing users to input JavaScript in a page and sharing it with other users?

I'm considering allowing users to input JavaScript in web pages and letting them share those pages with other users. What's the worst that can happen? Is there any way I can make it 'safe'? ...

Dynamically created radio inputs don't check in IE7

I came across a weird IE-specific error. It seems that when creating radio inputs with document.createElement, the resulting widgets do not respond to clicks. They grey out for a second when you click on them, but they do not become checked. It works as expected in FF3, but not in IE7. Any idea what's up with this? <html> <body> <form> ...

Getting absolute 'top' position from a mouse event (Javascript/jQuery)

On a mouseenter/mouseleave event, I would like to capture the absolute 'top' position of the cell of a table. So far, the event is attached like so: $('td[someAttr]').mouseenter(function(mouse) { // how do we get the td's top absolute position? //FYI: mouse.pageX and mouse.pageY would give the mouse position }); ...

Using Inline C# inside Javascript File in MVC Framework

I am trying to get inline c# to work in my javascript files using the MVC Framework. I made this little test code up. $(document).ready(function() { alert(<%= ViewData["Message"] %>); }); When this code is used inside of the view it works perfectly. When I get outside of my aspx view and try this in a javascript file I get ...

Breaking out of a PrototypeJS .each() loop

In this very contrived example, I have an array with 3 elements that I'm looping over using the .each() method. var vals = $w('foo bar baz'); vals.each( function(val) { alert(val); if( val == 'bar' ) { //This exits function(val) //but still continues with the .each() return; } }); I can easil...

Firefox: Get mouse coordinates of top-left corner of viewport

Good day everyone. I am working on a Firefox extension, and I want to pop up a tooltip at a certain offset from the mouse cursor. However, the problem comes when this offset is out of the viewport. It gets displayed but the user will have to scroll over there. I hope to enhance this by moving the tooltip pop-up within the current viewpo...

Creating a custom array within an array sort function in Javascript.

What would i need to put in the SortIP function to make the custom sort function sort the array by the last digit of the IP number. This doesn't work. function SortIP(a, b) { return a[0][3] - b[0][3]; } LAN = new Array ( ["ADSL Router", [192, 168, 0, 1]], ["Gary's Mac", [192, 168, 0, 15]], ["Network Switch", [192, 168, ...

Is my jQuery syntax wrong here?

Hey everyone, I am learning jQuery and I'm finding that this code is not working: <script type="text/javascript"> $(document).ready( /* Navigtion Stuff */ function(){ $('.menu ul').hover( function(){ $(this).parent().addClass("active"); }, function(){ $(this).par...

How to call a JavaScript function from PHP?

Hello How to call a JavaScript function from PHP? <?php jsfunction(); // or echo(jsfunction()); // or Anything else? ?> Please let me know. the follow of my program is, from xyz.html (on a button click) it call a wait() in an external xyz.js. This wait() call a wait.php function wait() { xmlhttp=GetXmlHttpObject(); var url="...

Javascript aliases

Hi all, my goal is to create a sort of "Javascript library," if you could call it that. I'm intending to use it to just manipulate pages as I browse the web, dynamically loading it as a greasemonkey script. The idea is to have "win" get mapped to window, "doc" -> document, "win.loc" -> win.location, and a few other convenience mappings...

JavaScriptSerializer.MaxJsonLength exceeded. What's the best practice for handling this?

I've got a large amound of data I'm sending down to the client using jQuery's $.ajax() function. I'm calling a method in a ASP.NET web service that returns the JSON data. Everything is great for most searches, but when I've got a large data set to return I run into a issue with the JavaScriptSerializer MaxJsonLength property. What's the ...

jquery autocomplete: Get "new" values when they're done

I've got a jquery autocomplete text box (multiple: true) used to set categories on an item, pretty much exactly like the stackoverflow tags. The autocomplete source is a list of objects, with formatItem overriden to do the correct display. What I'm trying to do is pull two lists out of it: one list of selected category IDs (array of in...

Javascript closure scoping issue

I'm trying to get a reference to cell and it appears null. If I'm understanding it correctly, I should be able to reference the variable. Correct? $('td[someAttr]').mouseenter(function(cell) { var timeoutId = setTimeout(function() { // what should variable cell be? }, 1000); }); OR $('td[someAttr]').mouseenter(functi...

How to relate ga:campaign and ga:pagePath (content) on Google Analytics Export API?

Using custom reports you are able to drill down on a specific campaign and then choose the Landing Page or content page that the individual visitor choose. When I try to retrieve the same information through the Google Analytics Export API, I get an error if I try to relate those two dimensions in my feed. Is there any success story ab...