javascript

window.onunload event

i am using confirm dialogue box on the window.onunload event.but when i click the cancel button it will navigate me to another page but i want to stay on that page. is this a problem of window.onunload event. please give me solution for this problem. also tell me another window event instead of it.But i do not want to use onbeforeunload ...

Javasript/MooTools - Better to save element in object property vs. accessing each time with $('elem')?

In terms of speed/memory efficiency, does it make sense to save an element (retrieved via $) to a variable in an object or use $ to access it each time? Does accessing object properties (especially if nested a few levels - object within object) perform faster than using $? ...

Compare jQuery Arrays with multiple DOM elements

Consider this: <div class="test">one</div> <div class="test">two</div> <script> var i1 = $('.test'); var i2 = $('.test'); console.log( i1 == i2 ); console.log( i1 === i2 ); console.log( i1.is(i2) ); </script> They all print false although they contain the same elements. One would think that .is() would work for comparing but it do...

Just-In-Time Asset Packager

I'm developing a PHP application which uses Twig (but that's unimportant) as the view layer. This view layer has a custom extension which allows me to register both remote style and script assets as well as style and script inline blocks. The system holds on to these references until the page has completed rendering, placing all of the...

Best way to insert an array of jQuery elements to the page

What's the best way of appending an array of jQuery elements to the page? I know that if I'm appending straight HTML tags then they should be collected together in an array then the array appended. This is the fastest method. However I have a collection of jQuery elements that have events created on them so I can't just concatenate stri...

How can I make page scrolling trigger mouseover events?

When the mouse starts hovering over an element because of scrolling (either by wheel, or by keyboard scrolling), it does not trigger a mouseover event on the elements it is hovering (Chrome 6 on OSX). What would be an elegant way to trigger the mouseover event for the correct elements when scrolling? ...

how to retrrieve all the styles of a node in tiny mce?

I want to retrieve the styles of a node inside the tiny mce instance. With getStyle, I can get only the styles, that I will provide as an argument. But, I don't know which styles will be applied to the node by user. I mean user can apply NUMBER of styles such as font, font color, borders. I simply need to get the whole string inside the ...

jQuery $(this).attr("id") not working

Hi guys, as the title says, I keep getting "undefined" when I try to get the id attribute of an element, basically what I want to do is replace an element with a input box when the value is "other". Here is the code: function showHideOther(obj){ var sel = obj.options[obj.selectedIndex].value; var ID = $(this).attr("id"); ...

How does JavaScript know where an element is the DOM?

I was writing some code in jQuery, like: $(".middleContent").not(this).slideUp(); (this = currently active .middleContent element) And I was wondering how JavaScript knew the elements index in the DOM. I know each object is unique, but if you have a few elements with the same class how does it distinguish between them? It is to do ...

Chrome Extension: communication between iframe and popup

Hi, I'm developing a Chrome extension, Which presents the user with an iFrame once the popup window is shown. I wish to invoke javascript function back on the hosting page. Now while I can access the "parent" object (it is not null) I can not invoke any method (like you would do with standard webpage that hosts an iFrame). Any ideas ho...

JAVASCRIPT: How to get the height of text inside of a textarea

What I want: So I have a textarea. I write Hello World into the the textarea. I want to get the Hello World's Height in Javascript. What I have tried yet: element = document.getElementById('textarea'); var textHeight = element.innerHTML.offsetHeight; or this: var textHeight = element.value.offsetHeight; But t...

how to create a button that plays a mp3 google tts

hello everybody! i'm new here but i hope you can help me. i'm trying to create a button that plays the text to speech mp3 that google generates. i'm creating a translator, so, what i want is to do something like google translate is (in some way). i've tried with javascript and actionscript but i couldn't make it work. i have this java...

Leading space is not getting retained in IE

Hi, I am working on one application, i am facing one problem on Internet Explorer while retrieving inner HTML of div. I have below input for retrieving : <div> This is first segment</div> I have used jquery script to extract content. i.e. $('div').html(); Output after using above statement : This is first segment Here not retr...

Javascript parseInt gives very unexpected results

I'm parsing a string to check if it's a date, and by chance we now discovered that my method doesn't work for dates in august or september. This is what I do (the input isn't really hard-coded, obviously, but for brevity...): var str = '2010-08-26 14:53'; var data = str.split(' '); // ['2010-08-26', '14:53'] var date = data[0].split('-...

loading iframes in a asp.net page

Hi i have a asp.net page which inherits form a master page where i load javascripts.I like to place a iframe withing the page which will point to a html(which contains the link to javascript) .Will my java scrips work ? ...

Why is this script element broken up into multiple document.write() calls?

Possible Duplicate: Why split the <script> tag when writing it with document.write()? I have frequently seen the following statement: document.write("<scr"); document.write("ipt language=\"Javascript\" type=\"text/javascript\" src=\"source url\"></scr"); document.write("ipt>"); What is the advantage of this? Why don't peopl...

Radio button check in iframe

I have javascript, which is in iframe. When i check radio button in iframe, on parent window change value. It working perfect on firefox, but not on IE... Can someone help me with this problem? <script type="text/javascript"> function getCheckedValue(radioObj) { if(!radioObj) return ""; var radioLength = radioObj.length;...

Prototype AJAX picking up Wrong response from PHP

Hi Everyone, I have a really confusing problem. I have a PHP script that polls another PHP script through Prototype. Now when I poll this page once everything is fine and it all reponds fine but when I poll a second time it returns an odd reponse. What I have is a piece of text: blah &pound; &pound; Now when this goes through Protot...

Using jquery from local file work only if work connection to internet

I have local library jquery <script src="/js/jquery.js" type="text/javascript"></script> i have ajax request .post('/default/AjaxAsinc/addnew',{'new':$("#name").val()},function(data){ for(var i;i< data.length.i++) { } },'json'); But it work only if connection to internet is active if connection is down i see next exception d...

How do you pass a javascript variable as an argument to a vbscript function (in the context of HTAs)?

I am writing an HTA and I need to pass a variable that I have in Javascript to a VBScript function. Can you please let me know how to do this? Here is a (nonworking) example of what I'm trying to do: <!DOCTYPE ... > <html> <head> <HTA:APPLICATION ID="chrome" APPLICATIONNAME="kiosk" ... /> ... <script type="text/javascrip...