javascript

Ask for confirmation on page unload

On StackOverflow when you're asking a new question, you have enter the question and if you decide to navigate away from the page you get an "Are you sure" confirmation. I'd like to do the same in my ASP.Net application: The user has to fill in a questionnaire and has the option to store his answers temporarely. If the user decides to...

How to append div tag dynamically in html using javascript/

Hi All, I am creating one div dynamically and want to add it inside another div. (js) var divtag = document.createElement("div"); divtag.innerHTML = xmlhttp.responseText;//Ajax call working fine document.getElementById('con').appendChild(divtag); html: enter code here <div id="con"></div> ...

How to internationalize string used in javascript code?

While developing AJAX program, I met the design decision to make string I18N in JavaScript.code. Some string is only used by JavaScript. For example. $('#submit').click(function() { $(#target).html('Please wait while submitting...').load(someURI); } I'd like to I18N the string 'Please wait while submitting...'. I'm not sure what's...

html: hover table column

How can I change the background column of an html table column when the mouse is over it? Preferably with css only. ...

Select a Tag with a Selector from a Text Variable using jQuery

I have a string which contains text and some <a> tags in it; I want to know how I can select a tag from the variable and loop it. I tried the following but it didn't work: var text = `some string here with <a href="#link">http:something.com</a> more string and more links also`; $('a', text).each(function() { var string = $(this)...

Javascript if(function_foo()) doesn't wait for function_foo() to complete

I have an if statement: if(authenticate_session("secret_password12345")){ alert("You are authenticated"); }else{ alert("Intruder alert!"); } and the javascript authenticate function, which makes an jQuery POST AJAX call to the server to do the actual authentication, and returns true or false: function authenticate_session(sess...

How to get the onclick calling object?

Hi, i need to have a handler on the calling object of onclick event ie <a href="123.com" onclick="click123(event);">link</a> <script> function click123(event) { //i need <a> so i can manipulate it with Jquery } </script> I want to do this without the use of $().click or $().live of jquery but with the method described above. ...

round to nearest .25 javascript

Hay, i need a hand. I want to convert all numbers to the nearest .25 So... 5 becomes 5.00 2.25 becomes 2.25 4 becomes 4.00 3.5 becomes 3.50 Thanks ...

How to send the Id of this anchor as a function parameter?

Edit: Sorry guys, I got the issue, Misspelled class name :( Hey, I got a quick question for your guys here. I have some anchor tags each of them points to a url of a certain user. The link id is the username. All the links share a css class (.userset). When a user clicks the link I need to issue an Ajax request -using jQuery.ajax metho...

How to show/hide a div from on mouseover/mouseout on a TR?

Is it possible to attach a popup (div) dynamically to a row in a table such that the popup is rendered by a mouseover, and hidden by a mouseout action? The code I put together ( see below ) refuses to render the popups, albeit the event handlers are called. Is what I'm trying to do really possible? From [http://stackoverflow.com/questi...

Javascript document.write() - Replace PNG with GIF?!

The Scenario I have an asp.net web application with a HTML/CSS front end. This all works fine but in Internet Explorer 6, the transparent PNG's that I use within the site are not transparent due to the poor design of this particular browser. Solutions Attempted I've already attempted various IE6 PNG Transparency fixes that didn't work...

compare operators

How do I Create a webpage using JavaScript that takes a number from the user and compares it against three ranges of numbers, unsing 3 functions, checklow(), checkmedium() and checkhigh()? ...

Ajax call not working in IE7 and FF.

Dear All, I have one js file with a ajax call which is working fine in IE6, but not in IE7 or FF. Can somebody help? window.onload = function() { var xmlhttp; var url = "myurl"; if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp = new XMLHttpRequest(); } else if (win...

Parsing Javascript (not JSON) in PHP

I have a php string containing the serialization of a javascript object : $string = '{fu:"bar",baz:["bat"]}'; The actual string is far more complicated, of course, but still well-formed javascript. This is not standard JSON, so json_decode fails. Do you know any php library that would parse this string and return a php associative arr...

Encapsulate menuItem with taglib, jsp, JS?

How could I encapsulate the authentication logic, the URL and the label of a Menu item when I make use of e.g. a Dojo MenuItem widget? What I currently have is this: <auth:isRole role="admin"> <div dojoType="widget.Menu.MenuItem"> <a href="<html:rewrite page="... complicated url ..."/>"> <bean:message key="label.goes.here"...

extract text from pdf in Javascript

Hi, I wonder if is possible to get the text inside of a PDF file by using only Javascript? If yes, what libraries should I use? I know there are some server-side java, c#, etc libraries but I would prefer not using a server. thanks ...

How can I retrieve the attributes of images?

How to retrieve the Image height and width from the IMG tag using jQuery and use this value in div style. like <div class=top>&nbsp;</div> <img src="source.jpg" width="200" height="400" alt="" /> <div class="bottom">&nbsp</div> I want to use the height of the Image and and apply to the DIV. like 400px-20px. div width. THanks ...

Firefox Extensions - best practices

Hi there I've been writing a Firefox extension, but have recently read a few articles explaining that it's bad practice to avoid variable name clashes by simple appending the application name to the front of the variable. Unfortunately I have been doing this. What is the best practice instead? I assume it's to somehow namespace the var...

Faux Timeout Triggers with JavaScript/jQuery & AJAX

Within jQuery.ajax we have the blessing of setting a timeout in milliseconds and an Error callback to process that timeout. However, the some people are simply on slow connection, with small amounts of patience. What I want to do is simply display a message stating "This is taking longer than usual". The Timeout arguement in jQuery w...

Google Analyics doesn't track links generated with AJAX

I run a website that has lots of affiliate links. These links are loaded via AJAX. I'd like to be able to track outbound clicks on these links. The standard approach to using Google Analytics to track links is to use the pageTracker._trackPageview() function. I've tried this to no avail. Here's my code: <a href=<?php echo $link_loc...