javascript

JavaScript - Validating a Hex in Opera?

Hi, This function works in Firefox, Chrome, IE9. Doesn't work in Opera. function isValidHex(hex) { alert(hex); var strPattern = /^#([0-9a-f]{1,2}){3}$/i; alert(strPattern.test(hex)); return strPattern.test(hex); } The hex going in is the same. The result of strPatter.test returns false in Opera and true in Firefox. Tested. ...

Is there a code editor that makes it possible to revert to a previous version?

I am coding in javascript a very big file and I keep wanting to go back to a previous version because of bugs I have created in the new version. Are there any code editors that allow you to revert to a previous version of the code? ...

How to send data to controller by using YAHOO connect and json

I can not send data to MVC controller using YAHOO connect library. Parameters query and filter are NULL. Where is the problem? // --- JavaScript --- // var callbacks = { // Successful XHR response handler success: function (o) { var messages = []; // Use the JSON Utility to parse the data...

How to change the background color of GInfoWindowTab

I have the follwing code to display tabbed infowindow but i am not able to change the background color of tabs function createMarker(point, name, address, imagepath, imagelocation) { var marker = new GMarker(point, gicons[imagepath]); var image1 = imagelocation.replace(/\\/g, "/"); var m1 = image1.slice(60, 80); ...

Image refuses to resize even via developer tools?

Hey all, I'm trying to customize a lightbox script (prototype) to make it resize images that are bigger than the viewport. I've successfully inserted a basic proof of concept to resize the lightbox overlay and everything that belongs to it, except for one important detail: the image itself won't resize. I've tried adding the resize fun...

variable defined in prototype are shared accross objects?

I have create object lik e this testObj.prototype = { cVar: 15, init: function(c){ /*initialization code*/ this.cVar = c; } }; var a = new testObj(10); var b = new testObj(20); Now both object's cVar values is 20. Are they sharing the variable? How i can get seperate variable for each object? ...

How to best use 'this' when its unavailable

say I create someObj like this var someObj = function(){ var self = this; //use this normally document.body.addEventListener('click',function(){ //use self because this is unavailable },false) } new someObj(); In the event this is not the someObj which id like to use but in this case the body element. Is there a best prac...

XML Parsing not working in IE

Hi All, I am trying to parse a XML file, it works perfectly in FF but dont in IE. Pls help debug this. The code is as follows. if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.open...

How to see the javascript errors of PhoneGap app in Xcode?

I want to debug my PhoneGap app in Xcode, but its Console can not show javascript errors. ...

how do i print currency format in javascript

hi guys, i have some price values to display in my page. i am writing a function which takes the float price and returns the formatted currency val with currency code too.. like fnPrice(1001.01) should print $ 1,000.01 ...

Download large PDF in javascript

I have a website which hosts large PDF documents, as well as some other file formats. How can I open up a download-dialog box in javascript so that the user can save the document to their computer? ...

How to define a success-event for http-requests with JavaScript/jQuery?

Considering a http-request and the server will answer with a pdf. I like to show a spinner, while the request is processing. How to do that? ...

Can I use normal Asp inputs instead of telerik's automatically generated ones??

Hi, How can I change <telerik:RadTextBox runat="server" ID="txtUserName" Width="238px" EmptyMessage="Lütfen 'Kullanıcı Adı' nızı giriniz."> </telerik:RadTextBox> in normal asp input form because in teleriks format I can not use onFocus="javascript:toggleMsg('msg-2')" or onBlur=...

Can an object's methods act on itself?

I'm not sure where to put some methods. Let's say I want to send an email. Which of the following options should I choose: email = new Email("title", "adress", "body"); email.send(); or email = new Email("title", "adress", "body"); Postman.send(email); Because how can an email send itself? And isn't it better to have a central ob...

How does the javascrpt creat a object?

function Person(name) { this.name = name; this.say = function() { console.info('I am ' + this.name); } } var p=new Person('stackoverflow'); Someone tell me that the above codes are equals to : function Person(name) { this.name = name; this.say = function() { console.info('I am ' + this.name); } ...

Incrementing [i] in the for-loop does not work

Hello everybody, this seems to be a simple question and I hope you can help me. I'd like to add that my code works the way I'm describing it. I'm not content with the way I solved my problem concerning my problem in incrementing [i] outside the for-loop. What I want is to get a sidebar menu shown when one hovers over an image. My CSS...

jQueryUI dialog box height grows too tall

I have a jQueryUI dialog box that loads its content the moment someone opens it using the "open" event to initiate the $('#dialogDiv').load() call. Works great except the dialog box grows extremely tall if there's a lot of content being loaded. What I want is to limit the height. The maxHeight jQueryUI dialog option would seem to work...

Javascript: Scope of a Variable across different Javascript files

Hi, I defined a variable in one of my JavaScript files. I want to access the value of that variable among JavaScript files. In one file I am initializing the value of that variable. I cannot access the assigned value in another JS files. Is there anything that I am missing ? ...

variable not defined

Error: s.currentBox is not defined, although container.onclick is firing before buttons[i].click var InputDigit = function(container,value, onchange){ this.init(container,value, onchange); }; InputDigit.prototype = { currentBox: null, init: function(container, value, onchange){ var self = this; con...

Javascript combine arrays or strings

I have the following dynamically generated strings: var stringA = ["a1", "a2", "a3" ... 'a400' ... 'a600']; // length 600 var stringB = ["b1", "b2", "b3" ... 'b400']; // length 400 How can I get an Array or string of both combined like this: var myString = ["a1b1", "a2b2", "a3b3" ... "a400b400", "a401" ... "a600"] ...