javascript

What is better for DOM manipulation - the DOM API or innerHTML?

I have the following code: tr = document.createElement("tr"); root.appendChild(tr); td = document.createElement("td"); td.appendChild(document.createTextNode("some value")); tr.appendChild(td); Well, this code is same as root.innerHTML = "<tr><td>some value</td></tr>"; The first version is probably a better way to go, because the b...

Javascript/Jquery - How do I get the element that the user has selected with their cursor?

If the user highlights the text within an <h1> with their cursor, how do I get that <h1> object? Or if they selected text within an <li>, how do i get that <li>? ...

What's wrong with this JavaScript object literal assignment?

Perhaps I'm just being dense, but I don't understand why Netbeans is telling me this is bad syntax: var events = { 'onkeyup' : 0, 'onchange' : 0, 'onclick' : 0 }; Lines 2-4 are squiggled red. ...

Clandestine .JS code - predictad_myLoc='';.......

what is the code below trying to do? I get a script error when debugging a small asp.net website. The browser stops and at the code below and the existance of .facebook. in code makes me Suspicious because i don't have it any where in all my web pages. Am curious as to what the code wants to do because i have no idea where that code exis...

Problem in integrating .js files for lightbox with previous ones

Hi guys, i am really messing up with this, could somebody help me here, please. what i am doing? -> I have developed an app in which I need lightbox effect(overlay) i.e when user will enter his name and click the button, he'll be shown a lightbox(simply telling him that process is going on. you need to wait.), he can then close the bo...

parseInt() returning incorrect value; DOB validation

Wondering if anyone could shed some light as I’m pulling my hair out over this one! I have written a simple function to validate a users Date of birth which is all well and good, or at least it was until I realised it wasn't working as expected! The function, as below, takes 2 parameters, dobNum (the value of an input field) and dmy ...

Trapping CTRL + P in javascript and calling a custom function for printing

Hi, I have a webpage where i show billing information in a pop. This popup is a DIV and not an new window. In that popup there are two div's one is to hold the print and close button and the other is to hold an iframe. Then reason is when the print button is clicked the content of the iframe is printed so that the print and close button...

How to close an iframe from inside that iframe

I have a an iframe with content from another PHP page on my server inside a modal window. I would like to figure out a way how to close the modal box with the iframe from inside the iframe. I am using this modal window plugin: http://opensource.steffenhollstein.de/templates/modalbox/ According to the documentation this method closes th...

Installing NodeJS on windows machine ?

Hello, How do I Install NodeJS on my windows Machine ?? I Searched All the available blogs for info, I found none of them are useful. so Is it possible for me to install Nodejs on my windows machine. If the answer is yes can anyone please explain the procedure. BTW I'm using windows XP ...

Attatching setTimeout() to window.opener from window in unload callback

Hi, I'm trying to do this: $(function() { var parent = window.opener; $(window).bind('unload', function() { parent.setTimeout(function() { parent.console.log('Fired!'); }, 200); } }); The example above works well in FF, Chrome etc. but not IE8. In the latter, the callback specified in setTimeo...

counteracting existing styles

I have a div with a padding, created and styled by Javascript. This div is created on a page with the following CSS rule: div { width: 100%; } This messes up, as it changes the width of my created div to what it naturally would be PLUS its padding (so I end up with buttons outside of the div borders). I can't statically set div wi...

How do you detect window.open(...) from within an HTA?

I am developing an HTA that will run as a kiosk in our reception area. This kiosk can display web-pages that launch new windows using the window.open() method. What I want to do is handle window.open() from within my HTA, so instead of spawning an Internet Explorer window, the new window will appear in a floating iframe inside the HTA. ...

How to make style of an element dependent on another element's style

I need to set some special style for an element if some other element is visible (which is indicated by a special css class and can change dynamically). I need to do this because the page rendering and it's behavior is fully controlled by some framework's code and I don't want to change it. I can put any content anywhere in the body of t...

How to strip the last part of a query string

Hi all, I need to isolate an id in a string using javascript. I've managed to get to the part where I get to the id but then I want to be able to string the rest of the string so that it only leaves the id number such as this: var urlString = "http://mysite.co.za/wine/wine-blog/blogid/24/parentblogid/15.aspx"; // if the blogid ...

How do I determine stale session versus no session in Java

Hi We have a site where the user gets a navigation bar to allow navigation of search results. When the user goes away for lunch or whatever, and the session times out, clicking next in the navigation which is still on the screen will show the next page, but will then lose the navigation since it was stored in the now stale session. Thi...

DataGrid row height problem when using formatter and image

I'm adding image to DataGrid cell with formatter. The problem is that the image gets partially cut out (limited to row default height). If I add static width and height attribute, problem is fixed, but in this case image sizes are dynamic. Also if I only add text, row height is grown correctly. <div dojotype="dojo.data.ItemFileReadStore...

cache eval() result

In Javascript, is it possible to cache the results of eval. For example it would be great if I could: var str="some code..."; var code = eval(str); //later on... code.reExecute(); ...

showing message while loading image

Hi, I m creating app. in facebook in that i m trying to show message to user while image is not completely loaded, the message is disappears when image is loaded completely and displayed to user. I used following code: function imageloaded() { document.getElementById('testing').setStyle('visibility','hidden'); } <div id="testing"> <fo...

How to determine if CKEditor is loaded?

Hi, How do I find out if CKEditor is loaded? I've looked through the API docs, but could only find the loaded event. I want to check if CKEditor is loaded, because if I load it a second time, my textareas disapear. Thanks! Yvan ...

Datetime conversion in JavaScript or jQuery

How to convert 10/jan/2010 to 10/01/2010 using JavaScript or jQuery Kindly help me ...