JavaScript - How To Detect If The User Clicks Cancel While Loading File
How to detect if the user clicked cancel while uploading a file ? Is there an event for it?
Similar TutorialsHello I want to add something to my web site. when the user clicks to download. i want to see a pop up screen which says your download has started. <script type="text/javascript"> function show_alert() { alert("Your Download Started!"); } </script> <input type="button" onclick="show_alert()" onclick="get value="Download" /> I dont get where should i put the download link Hi Everyone, I want to execute a script when the user clicks the button. Currently in my html doc. i have the button declared. <input type="button" id ="button" onclick='notEmpty() value="Play"/> When the button is clicked, i execute the notEmpty() function and I want to execute a script inside the notEmpty(). How can i do this? Thanks, Praveen I want to send a simple email with just email & subject only when the user clicks a link that opens a pdf. I'm thinking javascript is the best way to do this but I have no idea how. I have googled it a bunch but most information is about getting an email when someone clicks a link you send in an email. I don't want that. This is on a website. I'm not sure if php would be better to use. Any help would be most appreciated!
Hi, "This happens only in chrome browser" I am trying to design a website and it has a couple of radio button on the first page. I selected one radio button and navigated to the next page. On my second page, if i hit back button, the first page show the radio option that i selected(which is correct) but when I hit save and continue it throws a JS error "please select one option". Chrome forces me to re-click the radio option again. The application is MVC 3.5, C# Here is the snippet of the ascx Code: <%= Html.RadioButton("radAccnt", "abc", Account != null ? (entity != string.Empty ? (entity.Substring(0, 3).Equals("abc") ? true : false) : false) : false, new { id = "radAbc", onClick = "SetEntity('abc');", onBlur = "javascript:ValidateOnBlur(\"ValidateAccount('true');\");" })%> I had a alert in SetEntity(Value) function and value is empty when the back button is clicked. I did some research and found that Chrome does not cache the form data. If this is true is there a work around for this? Please help. Thanks. I found this code sample that when a user clicks somewhere on the image, then an "X" will appear. I would like to have the "X"s remain visible even when the user clicks on a different area of the image. As you can imagine, a user clicks clicks clicks then there are "X"s everywhere. How do I do this? Do I need to create more "div" tags with the mouse click locations? <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Mouse position</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <meta http-equiv="Content-Style-Type" content="text/css"> <meta http-equiv="Content-Script-Type" content="text/javascript"> <script language="JavaScript" type="text/JavaScript"> var posx; var posy; function getMouse(e){ posx=0;posy=0; var ev=(!e)?window.event:e;//IE:Moz if (ev.pageX){//Moz posx=ev.pageX+window.pageXOffset; posy=ev.pageY+window.pageYOffset; } else if(ev.clientX){//IE posx=ev.clientX+document.body.scrollLeft; posy=ev.clientY+document.body.scrollTop; } else{return false}//old browsers } function showP(){ document.getElementById("div2").style.visibility="visible"; document.getElementById("div2").style.top =(posy-10)+'px'; document.getElementById("div2").style.left=(posx-6)+'px'; } </script> <style type="text/css"> .div1 {position:absolute;top:100px;left:100px;visibility:visible;z-index:5} .div2 {position:absolute;top:0px;left:0px;visibility:hidden;z-index:1;color:black;} .div3 {position:absolute;visibility:hidden;z-index:10;font-family:monospace;font-size:20px;font-weight:900;color:black;} </style> </head> <body onmousemove="getMouse(event)"> <div id="div1" class="div1"> <img src="./yourImage.jpg" onclick="showP()"> </div> <div id="div2" class="div3"> X </div> </body> </html> Greetings, I designed a catalog browsing system for the college I work for, and I'm having a problem with one final thing, and it's going to drive me insane. The system uses individual PDF files for each page, and you can navigate using the controls on the side. It's not ideal, as it was made to replace a horrible system and has the limitations of the content being presented. That being said, I think it's pretty good. The trouble area is related to navigation: when you navigate the documents, some JavaScript detects the current URL of the content frame and updates the nav controls (previous and next page numbers) and table of contents links (bold, highlight) if they have changed. That part works fine. The problem area is with IE and PDF links. If you click a page link within the PDF, it opens that PDF file in the same frame. In FF and every other browser, the JS URL detection works fine. In IE, of course, it doesn't detect that a different PDF is being displayed. If it can't detect the new PDF file, and by extension, the file number, the nav controls don't work right. Now - before anyone asks - it DOES work in IE if you navigate to the PDF document by using the links in the navigation system that I built. It's just when you arrive at a PDF from another PDF that it fails. This is hard to explain more clearly, so take a look: http://www.aacc.edu/catalog/interactiveCatalog1011/ To see this in action, visit page 4, the table of contents. Click a page number link, for instance, page 9. Once it loads, click "next page" at the top left of the interface. In FF, it goes to page 10. In IE, it goes to page 5, since the JavaScript is unaware that the frame has changed PDF files. It doesn't make sense, since FF can see it plainly. My code is all out in the open. This thing has to be designed to run off of a CD as well as on the website. If I could use server-side scripting, it would be VERY different, I assure you. Any help with this would be phenomenal. I normally don't post for help, but I've searched practically all day, and I'm tired of running in to dead ends. Thanks so much! Jamie I guess this case applies to both popup windows opened by window.open() and by showModalWindow(). I have two buttons in popup window, "Cancel" and "Save". If the user clicks either button, there is a "process" at parent window before close() at popup being called. The problem now is, if the user click the "X" sign at top right corner of that popup window, how to trigger the "process"? I think I can do nothing in popup window since the closure is unexpected programmatically. Can I put some kind of listener in parent window to detect if popup is closed? Is there a way to tell Javascript to load data or a php file the re-direct to that page? Right now i have a script that will re-direct when a user comes to the page. It waits about 5 seconds to give it time. I wanted to know if there was a way to load it with JS or AJAX. Thanks for any help. Hey guys, I currently have a flash header .swf file as the header in my webpage. Problem is, it's 300 KB so it loads after everything else has already loaded, leaving a huge blank space where the .swf is suppossed to be until it finishes downloading. Is there a way I can tell my page to pre-load the .swf before everything else so that all elements in my page look like they load at the same? For example, with images I can do something like this: function MM_preloadImages() { //v3.0 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array(); var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++) if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}} } then: <body onload="MM_preloadImages('images/search.jpg','images/contact.jpg','images/home.jpg')"> Is there something like this for .swf? What I mean by this is how do you load an xml document that has been inputted as a string in a form. I would've assumed it was something like this, but this doesn't seem to be working. Code: <html> <head> <script type="text/javascript"> function loadXML(file) { var moz = (typeof document.implementation.createDocument != 'undefined'); var ie = (typeof window.ActiveXObject != 'undefined'); var xmlDoc; if (moz) xmlDoc = document.implementation.createDocument("", "", null); else if (ie) xmlDoc = new ActiveXObject("Microsoft.XMLDOM"); xmlDoc.async = false; xmlDoc.load(file); return xmlDoc; } </script> </head> <body> <input type="text" name="input1" size="15"/> <input type="button" value="LOADXML" loadXML(input1.value)"/> </body> </html> Where 'input1' would be an xml file in the same folder. ok guys im going to be honest here, i know nothing about javascript. ive been learning php and even that gets confusing at times. my issue: i bought a script off someone(php site) and it has a .php file that using .js files he had no idea how to fix the issue so im hoping you guys can help me fix it. this one .php page includes another .php file and 2 other .js files. i dont want to go and post every single file as one of them is like 1200 lines (i have if you like to hunt for errors) is there some code i can add in to make it show where its getting an error? i know you can in php and mysql the page get stuck on Loading... on the .php file which is line 647: AJS.setHTML(AJS.$('load'), 'Loading...') AJS.js & ocNewFixed.php (Starting page) all files can be downloaded he http://uppit.com/1233dylkbrfu/help.rar (too long to fit into 20k characters) Help would be appreciated. Hello, I am looking for a way to select a file from a list and load it into a webpage. The page and the files are stored on a sd-card for off-line usage, I know that listing files remote dynamicly needs a scripting engine but since the sd-card is on the client side that is not possible, but I can make a list of those files when creating them. It is intended for a datalogger on a tractor-puller, I create csv files with a bash script on the logger and for off-line viewing I use a javascript charting engine which loads the csv file, the files have the creation date as filename and I can make (and maintain) a list of files when creating them. The plan is that the we can select another data set (run) from within the browser and show that one. I have setup an example at http://www.dlogger.deserver.nl/test/ If someone can help me out this year starts good! im trying to onclick function on the button but in firebug it will say, function not defined, i even tried to do it with a internal script, but still it will not work. please help Code: <!DOCTYPE html> <html> <head> <script type="text/javascript" src="s/i.js"> </script> </head> <body> <button id="fihkhjsdk" onclick="ff();"> dsfh </button> <php code...> </body> </html> Hi, I'm currently working on my portfolio website and would like to have information about my movie clips be retrieved from an XML document when a thumbnail is clicked. I am building my website in HTML and would like to retrieve the Xml using JavaScript. Any help would be appreciated. My XML is valid and structured as such: <?xml version="1.0" encoding="UTF-8"?> <work> <motion> <reel> <title id="Demo Reel 2009" project="Self Promotion" client="Self"> <![CDATA[This demo reel is primaraly a collection ......]]> </title> </reel> . . . . These are my initial variable definitions and readXML function in javascript: <script language="javascript"> var xmldom, workNode, motionNode, printNode, fineartNode, displayNode, titleNode; function readXMLDocument() { xmldom=createDocument(); xmldom.async=false; if (xmldom.parseError != 0) { alert("An error occurred: \nError Code " + xmldom.parseError.errorCode + "\n" + "Line: " + xmldom.parseError.line + "\n" + "Line Pos: " + xmldom.parseError.linepos + "\n" + "Reason: " + xmldom.parseError.reason); } else { alert("Document: " + xmldom.documentElement); alert("Root: " + xmldom.documentElement.tagName); alert("Child: " + xmldom.documentElement.firstChild.tagName); alert("Xml DOM: " + xmldom.xml); } xmldom.load("workinfo.xml"); workNode=xmldom.documentElement; motionNode=workNode.firstChild; printNode=motionNode.nextSibling; fineartNode=printNode.nextSibling; } . . . . A call to function revealText is called "onClick" of a thumbnail as such: <a href="videopages/reel.html" class="vid" target="video" onClick="revealText(0)"> This is function revealText: function revealText(x) { var title, project, client, info; readXMLDocument(); displayNode=motionNode.childNode[x]; titleNode=displayNode.firstChild; title=titleNode.getAttribute("id"); project=titleNode.getAttribute("project"); client=titleNode.getAttribute("client"); info=titleNode.getNodeValue(); titleSpan.innerHTML=title; projectSpan.innerHTML=project; clientSpan.innerHTML=client; infoSpan.innerHTML=info; } </script> and these are the spans they are written to: <span id="titleSpan" class="vidinfo"> <span id="projectSpan" class="vidinfo"> <span id="clientSpan" class="vidinfo"> <p id="infoSpan" class="content"> If you have read this far, I REALLLLY appreciate it. And any ideas as to what is wrong would help alot. Hi, I have a JS file on site A which needs a few parameters from a short text file on site B. Since crossing domain boundaries in JS is problematic, the way I do it is that the JS actually opens an intermediate PHP file on site A which redirects to the destination page in site B. Here's how it goes: The call is made through: Code: On SiteA.com/myfile.js var theFile = getFile("intermediate.php"); var lines = theFile.split("\n"); var var1 = lines[1]; var var2 = lines[2]; var var3 = lines[3]; On SiteA.com/intermediate.php: <?php include("http://www.mySiteB.com/theTextFile.txt"); ?> The problem is that this takes a long time. I would really like to speed this up. For example - I thought of using a direct IP address, so that there won't be any need a DNS server (using Code: include("http://123.45.67.89/~myUsername/mySiteB/theTextFile.txt"); ) but this would expose me to hackers as it would make my Hostgator username visible. According to HG support the above format is the only way to access my subsite via direct IP. Any ideas on how to speed this up, either by bypassing DNS (but without exposing username) or by offering another way of reading data across sites? Suggestions for both JS and PHP files would be appreciated. I cannot set up a CDN here. This is really important for me! THANK YOU!!! Hi, I have some code that performs differently in Opera than it does in any other browser. So I have a stylesheet specifically for opera. Is there a way to do something like this, where I check the browser, and if it's not opera, then load the default sheet, otherwise load the opera-specific css? Code: <script> // Browser Detection Javascript // copyright 1 February 2003, by Stephen Chapman, Felgall Pty Ltd // You have permission to copy and use this javascript provided that // the content of the script is not changed in any way. function whichBrowser() { var agt=navigator.userAgent.toLowerCase(); if (agt.indexOf("opera") != -1) return 'Opera'; if (agt.indexOf("staroffice") != -1) return 'Star Office'; if (agt.indexOf("webtv") != -1) return 'WebTV'; if (agt.indexOf("beonex") != -1) return 'Beonex'; if (agt.indexOf("chimera") != -1) return 'Chimera'; if (agt.indexOf("netpositive") != -1) return 'NetPositive'; if (agt.indexOf("phoenix") != -1) return 'Phoenix'; if (agt.indexOf("firefox") != -1) return 'Firefox'; if (agt.indexOf("safari") != -1) return 'Safari'; if (agt.indexOf("skipstone") != -1) return 'SkipStone'; if (agt.indexOf("msie") != -1) return 'Internet Explorer'; if (agt.indexOf("netscape") != -1) return 'Netscape'; if (agt.indexOf("mozilla/5.0") != -1) return 'Mozilla'; if (agt.indexOf('\/') != -1) { if (agt.substr(0,agt.indexOf('\/')) != 'mozilla') { return navigator.userAgent.substr(0,agt.indexOf('\/'));} else return 'Netscape';} else if (agt.indexOf(' ') != -1) return navigator.userAgent.substr(0,agt.indexOf(' ')); else return navigator.userAgent; } if(whichBrowser() != 'Opera') { <link type="text/css" href="jquery-ui-1.8.13.custom/css/custom-theme/jquery-ui-1.8.13.custom.css" rel="stylesheet" /> } else { <link type="text/css" href="jquery-ui-1.8.13.custom/css/custom-theme/jquery-ui-1.8.13.custom.OPERA.css" rel="stylesheet" /> } </script> As of this writing, that code seems to break my page, as if it doesn't like loading a sheet based on an if/else clause. So, I have to rely on a third party external JS file to load into a site of mine. Problem is I have to have it (for ads), but once every blue moon the server fails to repond to the request (its down or unresponsive), and thus because the JS can't load, the site hangs. Is there a reliable js/ajax etc.. mechanism that I can use to set an allotted time and if the js isn't loaded, cancel the call or stop it so the page can load? Please advise. Caveats: I cannot host it, I cannot use php. Basically I was given a script call and I include it in the header of the page. I don't have alot of room to host, use various technologies etc.. other than what I am able to use without any backend/app scripting. Hi, Is there any way (any api) to display the confirm dialog box with yes/no buttons instead of ok/cancel in javascript. Can any one please let me know. Thanks in advance. The code below is supposed to cancel the default form behavior when it finds certain info missing. Currently, however, in spite of detecting missing info it allows the form submission to continue. Anyone see what wrong? Thanks. Code: var DOM = YAHOO.util.Dom; YAHOO.util.Event.onDOMReady(init); function init() { YAHOO.util.Event.addListener("contact_form", "submit", checkForm); } function checkForm() { var fName = DOM.get('f_name'); var lName = DOM.get('l_name'); if (fName.value == "") { DOM.get('f_name_error').innerHTML = "This field is required!"; fName.focus(); return false; } I use the Mouse Gesture Redox addon for Firefox 3.4 which allows javascript to be added for a gesture. I have found code which will perform different commands for the same gesture when a particular key is pressed. I would like the code to be disabled after each key press or a timeout (if a key is not pressed) until the same gesture is performed again. My attempts at coding to produce this effect have not worked. Can this be achieved? porman9 Code: document.onkeypress=detectKey; function detectKey(e) { if(e.which==97){BrowserOpenAddonsMgr();} else if(e.which==100){gBrowser.loadOneTab(currURL, null, null, null, false, false);document.body.focus();} else if(e.which==110){mgB_OpenTab();} else if(e.which==109){mgW_MinWin();} else if(e.which==114){mgW_Restart();} else if(e.which==117){mgB_UndoCloseTab();} } |