javascript

How can I simplify this jquery/javascript

I'm trying to improve my jquery/javascript syntax. Is there a better way to write this? if (ok) var mymsg = '<p id="ok-box">' + "You're good to go" + '</p>'; }else { var mymsg = '<p id="not-ok-box">' + "Error" + '</p>'; } I was thinking if jquery/javascript had a similar syntax to the following PHP syntax, ...

explorer: how to highlight text after using pasteHTML method ?

i replace selected text with pasteHTML method (Pastes HTML text into the given text range, replacing any previous text and HTML elements in the range.) in internet explorer. var ran = Editor.selection.createRange(); ran.pasteHTML('<span style="font-size:20px;">example</span>'); after replacing text, selection dissapears. how to highli...

What is equivalent code for window.location in jQuery?

I am currently using window.location for client-side redirection in jQuery. Is there any equivalent syntax to do client-side redirection? ...

Best way to pick up text in a HTML element that is in the parent node only

I have, for example, markup like this <div id="content"> <p>Here is some wonderful text, and here is a <a href="#">link</a>. All links should have a `href` attribute.</p> </div> Now I want to be able to perform some regex replace on the text inside the p element, but not in any HTML, i.e. be able to match the href within backticks...

Call php from javascript and return an array from php to Javascript function

Hi All, I want to write a function in javascript which will call the Getfilename.php and Get the $filesArray that is return in javascript. GetFilenme.php is another file and I am trying to access this from Config.html PHP : Getfilename.php <?php $dir = 'uploads/'; $dir = $_REQUEST['dir'] ; $filesArray = array(); $Counter = 0; $fil...

Textbox enter, invokes linkbutton in firefox, not in IE

hello everbody, i have a textbox on my form with a linkbutton next to it. the textbox' id is textbox1 and the linkbutton is lbSearch in the page_load event i add: this.TextBox1.Attributes.Add("onkeydown", "if(event.which || event.keyCode) { if ((event.which == 13) || (event.keyCode == 13)) ...

DOM Window unload event, is it reliable?

Can I rely on the window unload event to be triggered when a user closes a tab/window/browser? Edit: Found a list of what triggers the unload event in IE. http://msdn.microsoft.com/en-us/library/ms536973%28VS.85%29.aspx I would like to know in which edge cases the unload event won't be triggered. ...

JQuery/Javascript RDF plugin

Any ideas about JQuery plugins/Javascript libraries for working with RDF? ...

Error parsing XML file in JavaScript

I'm trying to parse a simple XML file but I'm having trouble trying to obtain a value I need. The current error message I'm getting says node is not an object or is null. I'm testing on both I.E. 6, 7, FF 2,3 Here's the XML file: <bookstore> <appSettings> <add key="myKey" value="myTargetValue"/> </appSettings> </bookstore> He...

onchange event never happens on IE while ok with firefox

Hello It might be a beginner question but I can't understand why the onchange event is never called by IE while it works Ok with firefox. <input type="text" id="mytext" size="48" value="" onchange="execute()"/> <button type="button" onclick="execute()">Go</button> The execute function is called when the button is clicked but not when...

How to have hover effects on input boxes in Internet Explorer 6

Hey, Im looking how to have hover effects on input boxes in Internet Explorer 6? Im using YUI if I can utilise that. Thanks ...

Is there a JS debugger that will quickly step through a program and list the functions called in order?

I find myself with a fairly complex JavaScript program and a bug that would be easier to solve given an ordered list of all the functions called. I could generate a list manually by setting a break point, and stepping through the code line by line. I'm hoping there is something faster out there. The Firebug profiler isn't much help as ...

jquery disable/enable submit button

i have this hmtl: <input type="text" name="textField" /> <input type="submit" value="send" /> how can i do something like this: -when the text field is empty the submit should be disabled(disabled="disabled") -when something is typed in the text field to remove the disabled attribute -if the text field becomes empty again(the text is...

Please wait modal overlay before waiting for a function with a heavy workload without setTimeout()?

This is a simplified example, to make sure that there are no asynchronous fading/animation functions involved. I want, that the background is red when the function with the heavy workload works and turns to black, when it is ready. What actually happens is, that most times the background will turn directly to black, after the function i...

jqGrid new setup giving JS error: ts undefined

I am trying play around with jqGrid (and a few others). Doing the initial setup for jqGrid is giving me a JS error. I must have imported the scripts in wrong order or something silly, but being so new to that widget its hard for me to figure it out. Here is the page that is giving me the problem (go there and see error for yourself): ...

Getting lastIndexOf on a Dropdown

Here's my attempt to get the last item in the dropdown and check it: if (day.lastIndexOf(day.length) == 28) { ..do something } day var is set to reference dropdown control. Obviously I am not doing this right. How do I know where I can apply lastIndexOf on a dropdownlist? How do I get at it's array? I tried this also but it does...

JavaScript - find date of next time change (Standard or Daylight)

Here's a timely question. The rules in North America* for time change are: the first Sunday in November, offset changes to Standard (-1 hour) the second Sunday in March, offset changes to Daylight (your normal offset from GMT) Consider a function in JavaScript that takes in a Date parameter, and should determine whether the argument ...

Which javaScript framework for cross-domain?

Hi All, I am building a web service that will make heavy use of cross-domain GET and POST data, and then update some lightbox or similar windows on the client. Is there one JavaScript framework that is better at this, or more importantly, a framework which I should avoid? I want to be able to put controls in the boxes. Really sexy bo...

How to "properly" create a custom object in JavaScript?

I'm still trying to understand JavaScript, and I wonder about what the best way is to create an object that has properties and methods. I have seen examples where the person used "var self = this" and then uses "self." in all functions to make sure the scope is always correct. Then I have seen examples of using .prototype to add proper...

Is there any tool for commenting JavaScript code?

Hi All, Is there any tool for javascript commenting as it is in c# like ghost doc. /// <summary> /// Method to calculate distance between two points /// </summary> /// <param name="pointA">First point</param> /// <param name="pointB">Second point</param> function calculatePointDistance(pointA, pointB) { ... } there any tool...