javascript-events

window.onbeforeunload not working

非 Y 不嫁゛ 提交于 2019-12-17 06:05:11
问题 I have a form where the input fields are saved onChange. In firefox (5) this works even when the window is closed, but for Chrome and IE it doesn't and I need to be sure that I'm saving this data even if they try to close the window after they've typed in a field but an onBlur event hasn't occured (ie they've typed something into a textbox, but haven't tabbed out of it). I have read the following SO articles on using window.onbeforeunload: article 1 article 2 if I use the following: window

Prevent parent container click event from firing when hyperlink clicked

对着背影说爱祢 提交于 2019-12-17 05:11:28
问题 On my web page I have a list of files. Each file is in it's own container div (div class="file"). Inside the container is a link to the file and a description. I wanted to allow a user to click anywhere on the container to download the file. I did this by adding a click event to the container and retrieving the href of the child link. As the file opens in a new window, if the user actually clicks the link, the file opens twice. So I need to prevent the parent container click event from firing

Detect if the iframe content has loaded successfully

浪尽此生 提交于 2019-12-17 05:03:37
问题 I have a widget that contains an iframe. The user can configure the url of this iframe, but if the url could not be loaded (it does not exists or the user does not have access to internet) then the iframe should failover to a default offline page. The question is, how can I detect if the iframe could be loaded or not? I tried subscribing to the 'load' event, and, if this event is not fired after some time then I failover, but this only works in Firefox, since IE and Chrome fires the 'load'

how to block users from closing a window in javascript?

雨燕双飞 提交于 2019-12-17 04:26:24
问题 Is it possible to block users from closing the window using the exit button [X]? I am actually providing a close button in the page for the users to close the window.Basically what im trying to do is to force the users to fill the form and submit it.I dont want them to close the window till they have submitted it. guys i really appreciate your comments,im not thinking of hosting on any commercial website.its an internal thing,we are actually getting all the staff to participate in this survey

How to pass parameter to function using in addEventListener?

不打扰是莪最后的温柔 提交于 2019-12-17 04:18:06
问题 In the traditional way to add event listener: function getComboA(sel) { var value = sel.options[sel.selectedIndex].value; } <select id="comboA" onchange="getComboA(this)"> <option value="">Select combo</option> <option value="Value1">Text1</option> <option value="Value2">Text2</option> <option value="Value3">Text3</option> </select> But I wanted to adapt to the addEventListener way: productLineSelect.addEventListener('change',getSelection(this),false); function getSelection(sel){ var value =

window.resize event firing in Internet Explorer

我只是一个虾纸丫 提交于 2019-12-17 04:13:09
问题 As you are aware, in Internet Explorer, the window.resize event is fired when any element on the page is resized. It does not matter whether the page element is resized through assigning/changing its height or style attribute, by simply adding a child element to it, or whatever -- even though the element resizing does not affect the dimensions of the viewport itself. In my application, this is causing a nasty recursion, since in my window.resize handler I am resizing some <li> elements, which

Is there a way to get SSL certificate details using JavaScript?

南笙酒味 提交于 2019-12-17 04:08:15
问题 I'd like to gather certain details of an SSL certificate on a particular web-site. I know this is straightforward using the openssl tool on Linux/MacOSX. However is the same or similar possible in JavaScript? I understand that the browser handles socket connections and that the SSL handshake occurs prior to any party sending data. However in an XMLHTTPRequest, I'd like to know if its possible to get these details as some sort of response code etc? 回答1: This information simply isn't exposed to

Is there a way to get SSL certificate details using JavaScript?

此生再无相见时 提交于 2019-12-17 04:08:10
问题 I'd like to gather certain details of an SSL certificate on a particular web-site. I know this is straightforward using the openssl tool on Linux/MacOSX. However is the same or similar possible in JavaScript? I understand that the browser handles socket connections and that the SSL handshake occurs prior to any party sending data. However in an XMLHTTPRequest, I'd like to know if its possible to get these details as some sort of response code etc? 回答1: This information simply isn't exposed to

Why don't audio and video events bubble?

泄露秘密 提交于 2019-12-17 04:06:08
问题 I was wondering why some javascript of mine would not work until I figured that the audio events did not bubble up the DOM tree, e.g. the timeupdate -event. Is there a rationale for not letting the events of the audio- and video-tag bubble? 回答1: The reason why event bubbling exists is solve the ambiguous question of which element is the intended target of the event. So, if you click on a div, did you mean to click the div, or its parent? If the child doesn't have a click handler attached,

How to detect new element creation in jQuery?

时光毁灭记忆、已成空白 提交于 2019-12-17 04:05:47
问题 Lets say I have the following code that returns number of anchor elements on a page: function getLinkCount() { alert("Links:" + $("a").length); } If I call in on document ready it would work as expected. But what if now a new link gets inserted into a page dynamically through javascript, how can I get notified to run link counter function again? (I have no control over a script that could create a new link). Basically I am looking for something similar to live() only that would be watching