javascript-events

Javascript regex URL matching

旧巷老猫 提交于 2019-12-23 18:11:17
问题 I have this so far: chrome.tabs.getSelected(null, function(tab) { var title = tab.title; var btn = '<a href="' + tab.url + '" onclick="save(\'' + title + '\');"> ' + title + '</a>'; if(tab.url.match('/http:\/\/www.mydomain.com\/version.php/i')) { document.getElementById('link').innerHTML = '<p>' + btn + '</p>'; } }); Basically it should match the domain within this: http://www.mydomain.com/version.php?* Anything that matches that even when it includes something like version.php?ver=1, etc

Audio event does not trigger jquery on play event

偶尔善良 提交于 2019-12-23 17:38:49
问题 I try to execute a function on an audio play event : jQuery('audio').on('play', function () { /* ... */ }); But my element is not present at the time this function is executed, so it's not selected. Instead I have the habit to use a different syntax when I need to trigger event for dynamic added content : jQuery('.constant-container').on('play', 'audio', function () { /* ... */ }); Where the .constant-container does not change. But this solution does not seems to work, the audio element does

user events related to contenteditable

[亡魂溺海] 提交于 2019-12-23 16:37:52
问题 I am a beginner in Javascript & HTML5 Suppose I have a contenteditable <div> [block-level] element in my HTML5 window. What is the exhaustive list of Javascript events which the user could trigger by modifying this element (or some sub-elements) thru user interaction ? How should I code in Javascript to reject some user action? or change the DOM... (i.e. replace some TextNode with e.g. some <span> ) It seems that the input event cannot "undo" or "reject" some user action... FWIW, at this

In Chrome, <embed> resource isn't loaded when $(document).ready() is triggered. Why?

依然范特西╮ 提交于 2019-12-23 16:34:44
问题 In FF and IE, the SVG (SVG) document is retrieved when $(document ).ready() is called. In Chrome, the getSVGDocument returns null instead when $(document ).ready() is called. (Although it seems to find it approx 7ms after, as shown by the setTimeout .) Why does Chrome not find the loaded <embed> SVGdocument at moment of $(document ).ready() , but FF and IE do? (I don't want to have to use a setTimeout(7ms) just to wait for Chrome to catch up!!! Because that's... lame.) The code simple code

New Google Analytics event tracking wont work on mailto

徘徊边缘 提交于 2019-12-23 16:19:00
问题 I'm using the latest google analytics code: (function(i,s,o,g,r,a,m){ i['GoogleAnalyticsObject']=r; i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date(); a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=1; a.src=g;m.parentNode.insertBefore(a,m) }) (window,document,'script','//www.google-analytics.com/analytics.js','ga'); ga('create', 'XXXXXXXXX', 'XXXXXXXX'); ga('send', 'pageview'); I've got event tracking to work on a download link using the following:

JQuery & Timer :: Updating the text of a hyperlink from a webservice

霸气de小男生 提交于 2019-12-23 16:07:15
问题 What I'm to figure out how to do is execute a webservice on a remote server to determine how many messages there are available to read and populate the text of a hyperlink with the message count. The trick is I'd like this to be fired from a timer (every 5 mins for example). Here's what I've been messing with $.ajax( {type:'Get',url:'http://foobar.com/ws',success:function(messageCount) { $('a.message').text(messageCount + ' Messages'); } }) but admittedly, am utterly clueless when it comes to

How do i submit a form with jqueryui dialog button,

南楼画角 提交于 2019-12-23 15:48:17
问题 I want to submit a form using jqueryui button. I had some code but it doesn't work. Here is the code: <script type="text/javascript"> function findUrls() { var text = document.getElementById("text").value; var source = (text || '').toString(); var urlArray = []; var url; var matchArray; // Regular expression to find FTP, HTTP(S) and email URLs. var regexToken = /\b(http|https)?(:\/\/)?(\S*)\.(\w{2,4})\b/ig; // Iterate through any URLs in the text. if( (regexToken.exec( source )) !== null ) {

TypeError: object is not a function

删除回忆录丶 提交于 2019-12-23 15:11:53
问题 I'm developing this webapp for my school. The page is supposed to filter entries by the url parameter "class". This works fine as far as i can tell, but when i try to change the filter it gives "TypeError: object is not a function". What am i doing wrong? <html> <head> <TITLE>Cancelled lessons</TITLE> </head> <body> <script> function filter(text){ text = text.toLowerCase(); for (i=0;i<lessonList.length;i++){ if(lessonList[i].innerHTML.toLowerCase().indexOf(text)==-1){ lessonList[i].style

Asynchronous/Synchronous Javascript

本小妞迷上赌 提交于 2019-12-23 12:49:33
问题 I'm having some trouble understanding the difference between asynchronous and synchronous Javascript, and was hoping someone could shed some light on this. I know Javascript is inherently synchronous, but you can use asynchronous events/callbacks to alter your program flow. However, what happens if you call a function with no callback that contains AJAX? For example, if I have the following code, where foo() contains some sort of server query and foobar() contains some output text: foo();

Run Javascript function when object content has been loaded

纵然是瞬间 提交于 2019-12-23 11:46:12
问题 How do I run a Javascript function when the content of an <object> has been loaded? The DOMContentLoaded event fires before that, and things that rely on it like JQuery's $() likewise. Compare this to this. The first example fails because the function is executed when the external SVG hasn't been loaded. The second example polls for the elements it wants to change and only then executes the relevant code, and succeeds. Polling works in practice, but is there a better solution for this?