javascript

Javascript code working in the html file not working when taken as a string in C++

I have html file with javascript code the contents of the file are as under: I tried this code on Safari and it was working fine. But when I tried this on Firefox, it’s not working. Can any one suggest how to make it working on firefox. <html><head></head><body><button type="button" onClick="handleButtonClick();">undo</button> <button...

jQuery - Limiting server hits based on Last Key Press?

I'm looking to learn how to build something that detects key-presses in order to throttle a function. Something like: var LastKeyPress; function hitTheServer() { if LastKeyPress > 2 seconds ago { hit the server and do stuff LastKeyPress = now(); } } What do you think? Maybe this is built into jQuery? Also, its something that...

Object Expected error in IE7 - problem with function scope?

Hi - I'm having what I hope is a simple-to-fix issue. Basically, I've got one block of javascript containing the function, and then I'm trying to call it from another block of javascript (within a jQuery $(document).ready function). Whilst it works fine on Firefox, I get an 'Object Expected' error in IE7. It's probably something to do w...

Regex returning a value in IE, 'undefined' in Firefox and Safari/Chrome

Have a regex: .*? (rule1|rule2) (?:(rule1|rule2)|[^}])* (It's designed to parse CSS files, and the 'rules' are generated by JS.) When I try this in IE, all works as it should. Ditto when I try it in RegexBuddy or The Regex Coach. But when I try it in Firefox or Chrome, the results are missing values. Can anyone please explain what t...

Repeat/Clone a <tr> element using jQuery's clone() function

I am trying to clone a template of a which will be populated with data and then inserted into a table. I'm currently able to use the same .clone() function with other elements on the same page but jQuery refuses to see and clone the template (I'm guessing because its not a block element). Here is the template: <tr id="search_result_...

Why does this JavaScript work on Safari, but not Firefox?

I have the below HTML file. I tried the code on Safari and it was working fine. But when I tried this on Firefox, it’s not working.Can anyone suggest how to make it working on firefox? On click on undo button I want to retrieve contents from the jsp file. Thats working when I used this code on safari on my mac.. but when I open the same...

Storing data in MySQL Server Database using AJAX

I'm very new at using JS and AJAX. Currently I'm working with Google Maps API and I need to store some locations (lat,long) to the server. What I want to do is store some sort of data in my existing MySQL database in server. I have got some good example as well like the following- http://www.tutorialspoint.com/ajax/ajax_database.htm N...

Magento - javascript reliance = huge usability issues

Ok this is a bit of a rant and a question combined - Why the hell is magento so reliant on javascript?? This goes agaisnt all usability guidelines. WHats so annoying is that it even uses buttons instead of correct form submit elements. Why? This makes no sense what sense at all to me. Why is this and is there a way around it? ...

Shortest route with no set destination in Google Maps V3?

So I'm just learning javascript to mess with the Google Maps API. I was wondering if anyone had an elegant solution to this problem I'm running into. A Google Maps route request must contain three things (origin, destination, and travelMode). My travelMode will always be DRIVING. The origin will always be wherever the user is located. ...

How is the swoosh done on beautyoftheweb.com?

On Beauty of the Web, there is a purple/blue swoosh at the beginning, if you are in IE9 or Chrome. How is that done? What is that? How come it only displays in IE9 and Chrome? ...

Primefaces, JavaScript, and JSF does not work well together or am I doing something wrong

Here is something so simple <p:commandLink value="Tom" onclick="document.getElementById('tom').focus()"/><br/> <input id="tom"/> When u click on the Tom, the textbox get focus. Great, now try this <p:commandLink value="Tom" onclick="document.getElementById('tom').focus()"/><br/> <h:inputText id="tom"/> <br/> when I click nothing ha...

Contenteditable adds a <br> when I hit space

I'm not sure why, but if you have an element with contenteditable enabled, the first time you enter a space, it'll append a <br> tag into the element. If the element has a space in it by default (<p contenteditable="true">this is a test</p>), it'll be fine, but as soon as the user hits that spacebar (or even copy+pastes a space characte...

Javascript Split properties into Object exclude inside Strings

What is the best method for splitting or extracting the css properties out of as string and into an object? var cssProperties = 'background:green;content:"Content;";color:pink;'; The above should result in the following var theObject = { background:'green', content:'"Content;"', color:'pink' } Unfortunately I can not ju...

Set default button on html elements with jquery plugin

I am looking at writing a jquery plugin that takes a number of input elemts such as input elements, textareas, select html elements etc and once the enter key is pressed in any of the above items, a input button is triggered. As such, the button is set as the default for the fields. Any tips on doing this? ...

Possible to detect if a user has multiple tabs of your site open?

I'm just thinking about the whole site registration process. A user goes to your site, signs up, and then you tell him you've sent him an email and he needs to verify his email address. So he hits Ctrl+T, pops open a new tab, hits his Gmail fav button, doesn't read a word of your lengthy welcome email, but clicks the first link he sees...

YUI API Dual Slider control question

I'm using the YUI 2.7 library to handle a dual-slider (range slider) control in a webpage. It works great-- however, I wanted to allow users to switch the range values by Ajax-- effectively changing the price range from "0-50,000" to a subset (eg. "50-250") without reloading the page. The problem is that it appears the values from the ...

InnerHTML issue

How do I get the values of textboxe's along with innerHTML? For example, if I have <html> <head> </head> <body> <div id="getvalue"> <p><input type="text" name="username" id="username"></p> </div> </body> </html> I need the innerHTML of the particlular id="getvalue" along with the textb...

How do I get the Closure Compiler to stop complaining about union types when calling a function?

I'm seeing this in particular when using the jQuery-1.4.3 externs file. The javadocs for that reads /** * @param {(string|number|function(number,number))=} arg1 * @return {(number|jQueryObject)} * @nosideeffects */ jQueryObject.prototype.width = function(arg1) {}; I have a call that looks like this: var w = $(window).width(...

Pass along get params?

I want to use ajax to retrieve some JSON from another page, but I want to pass along the same GET params that were used to request the original page. How do I do that? Does JS store them in a dict somewhere? Or is there a jQuery solution? $.ajax({ url: 'mysecretwebpage.com/supersecret', data: ??? }); ...

how to display multiple line file contents in javascript

I have a page where onclick on a button displays the text content from the file in the text area on the page javascript function function displayOutput() { <?php $logfile = "hello"; $fh = fopen($logfile, 'r'); $size = filesize($logfile); if($size == 0) { ...