javascript

Ajax breaks frameset in IE only

I have an issue with frameset breaking down and I have gotten a little help here on the forum. Now I have finally tracked down when things go south so here is my current problem. 1 I have a frameset with Top, Menu and Main 2. Links in Menu open views in Main 3. This breaks down on saving documents in Main. After saving all links in Menu...

Positioning a div relative to scroll position

This script shows and positions a div like: function myfunction() { obj.style.visibility = "visible"; obj.style.width: "100%"; obj.style.height = "100%"; obj.style.position = "absolute"; obj.style.top: "0px"; obj.style.left: "0px"; obj.style.z-index = "44"; obj.focus() } and so on <b onclick="m...

How to access JS variable in C#

Let's say I have <div id="blah">500</div> (Context: asp.net aspx page) How do I allow a c# code access that value? <% int numberiwant = ###; // Ideally 500 %> I was thinking of something along the lines of jQuery: <script type="text/javascript"> var value = $('#blah').html(); // Then do some magic and pass to c#? </script>...

PrototypeJS mouseover menu

So i have this menu that is supposed to display submenus which are defined in object initialization by using script.aculo.us effect appear ( mouseover ) and hide them using effect fade ( mouseout from link and menu ). The problem is that i did the job with showing and hiding menus but when i get my mouse out of the link that is supposed ...

Creating a singleton from any given class in javascript

I have written the following function that permits creation of singleton classes from given classes: function SingletonFrom(Constructor) { return function() { var self = arguments.callee; if (self._instance === undefined) { switch (arguments.length) { // this is ugly case 0: self._instanc...

Select value of a RadioButton

I want to select a particular RadioButton based on its value <input id="RadioJ" type="radio" name="grp1" value="AAA" /> <input id="FaroK" type="radio" name="grp1" value="BBB" /> <input id="MartreLK" type="radio" name="grp1" value="CCC" /> Something like this: var radio = radio button whose value is BBB Another thing i am looking is...

Getting index from value in JavaScript

Is there a function/method to retrieve the index of an item in an array from its value in JavaScript? In other words I'm looking for the JavaScript equivalent for the Python .index() lists method: >>> ['stackoverflow','serverfault','meta','superuser'].index('meta') 2 Does the wheel already exist or have I to reinvent it? ...

ajax request :document.getElementByID('txtHint).innerHTML

I have following in my HTML code: <div id="txtHint"><b>Person info will be listed here.</b></div> and I have following in my JavaScript: document.getElementByID('txtHint').innerHTML = 'hi'; I have a problem; the code stops executing at the above JavaScript line. The statements following the above JavaScript line are not executed. H...

Best Practices Question: Modern Menu with Sub DIVs and Alternate Page States

Greetings! I am interested to your feedback regarding best practices for handling a website menu system using modern methods (jQuery?). The old way (in place currently): <div id="menu"> <ul> <li class="navHotel"><a href="#" onmouseover="MM_showHideLayers('hotel','','show','tour','','hide','location','','hide','attractions','','h...

Problem with JavaScript closure

Hey guys, I am stuck at the following code. At first I'll describe the use-case: The function "addPreset" gets called with an instance of ColorGradient. When calling this.listController.addItem(...) a callback function named onSelect ist supplied, which gets called everytime the onSelect-event on the listController-item is triggered. Wha...

'' equals false in Javascript? What would be the safest way to distinguish between '' and boolean false?

We use an external API whcih returns '' or boolean false while Javascript seems to find the both equal. for example: var x = ''; if (!x) { alert(x); // the alert box is shown - empty } if (x=='') { alert(x); // the alert box is shown here too - empty } var z = false; if (!z) { alert(z); // the alert box is shown - displays 'fal...

Implement Icallback

how to implement the callback for more than one element. I have a form with various fields like description, title etc.. I need to check whether those fields contain the listed stop words which i get from database.if any of the fields contain the word then i must not submit the form and indicate the error at the respective field. ...

Element is not defined jQuery $(element).remove()

Hello SO: I have this javascript that adds a form field, along with a link to remove that field: var fieldCount = 0; function addField() { var name = 'file' + fieldCount; var row = 'row' + fieldCount; var str = '<p id="' + row + '"><label for="' + name + '">File to upload: <input type="file" name="' + name + '" id="' + name...

Getting inputs to auto-complete/suggest when preventing default form behavior

Hi Guys, Interesting bug here that seems to be limited to IE and Webkit. I have a basic form setup: <div id="output">Form output is displayed here</div> <form id="myForm" action="#" method="post"> <input type="text" name="username" id="usernameInput" /> <input type="submit" value="Submit" /> </form> Now if I just submit the form thro...

Safe way to make behavioral CSS trigger based on Javascript availability

I have been using this chunk of code to programmatically check if Javascript is available and use different behavioral CSS. If Javascript is disabled, it will only show a normal unordered list. If javascript is enabled, the list will be transformed after page load and then displayed to the user (avoiding the possible redraw/flicker of...

Qt: Is is possible to get the QScriptEngine from QWebFrame?

I need to get access to the javascript QScriptEngine in a QWebFrame. Is that possible? Well, at least I think I need access to it. In response to a javascript call I need to allocate a new object, return it to javascript and hand ownership of the object to javascript so that it can be garbage collected. It looks like QScriptEngine::n...

IEs understanding of 'this'

In this code, Firefox sees 'this' as the element that was clicked and passes the href attribute through the right way. IE seems to think that 'this' as [object window] instead. How would I get this to work the same way in both browsers? Note: jQuery would be lovely, but is not an option for this project var printElem = getElementsByCl...

Which is the best method to redirect users from an existing website to an existing WP blog?

Hi, I have a website with around 500 html pages. I have now posted all these html pages into my blog as blog posts. I now want to now redirect users from the page to the blog. I could do that using mod_rewrite or JavaScript Since Google will re-index these posts, which of the these two methods would be a better option for SEO? Kindly ...

How can accomplish a dual div swap on rollover?

I am looking for advice on a way to accomplish this. Given the following: [Div A (contains an image)] [Div B (contains a horizontal list of 8 or so text links)] [Div C (contains text)] Upon rolling over any link in Div B, how can I have Div A and Div C swap their respective contents out to something different that corresponds to the co...

Internet Explorer 8: Navigate to users home page

I've been using the following script for a few years now to navigate to the users home page when a button is clicked. However, with the start of IE8, this does not work as it appears "about:home" is no longer valid. if(window.home) { // for everything but IE: window.home(); } else { // for IE: window.location = "about:home"; // ...